Added type cast for error messages as well