locked
Error tracking message RRS feed

  • Question

  • User546194788 posted

    In a project, I use try...catch...end try to track error and created two functions.

    One function to send an email including "ex.ToString()" to me.

    The another function displays "ex.Message" on the screen.

    What is the difference between "ex.ToString()" and "ex.Message"?

    try

    '''''

    Catch ex As Exception
    mydisplayfunctionToEmail(ex.ToString())
    mydisplayfunctionOnScreen(ex.Message)
    End Try

    Friday, July 17, 2020 3:32 PM

All replies

  • User753101303 posted

    Hi,

    Just have a look. ex.ToString() includes the full exception details (call stack and the whole exception chain if you have an exception which throw another exception etc...).

    ex.Message is just the error message for the outer exception.

    I prefer to show a generic message as the user usually can't do anything (and possibly understand) this kind of message and it could leak sensitive information. ex.ToString() is much better than ex.Message for developers so that they have the full picture about which error happens.

    Friday, July 17, 2020 4:00 PM
  • User-1330468790 posted

    Hi aspfun,

      

    How is your problem going?

    If you feel the answer does help, I suggest you can mark the answer as this will help other people who faces the same issue to find the right answer faster.

     

    Thank you for understanding.

    Best regards,

    Sean

    Wednesday, July 29, 2020 9:42 AM