Revised the function to print errors or warnings.