Move warning messages to generalized function.