Formated the error message when an exception occurs