Improved error message formatting