Check the error message before printing it.