Coffeehouse Thread

6 posts

Forum Read Only

This forum has been made read only by the site admins. No new threads or comments can be added.

A good Tutorial on Error Handling

Back to Forum: Coffeehouse
  • User profile image
    Shrage

    I could not find a good book or online tutorial how to make good error handling and error display in a shrink wraped application writen in C# or Vb.net. can someone help me with that? here is an example of a situation

    I have a utility function that loads up lists in memory. lets call it RefreshList, if there is any error happening in this function i need to display a clear message like "Could not reload the lists, [Reason]" but where do i put the code to display the message 1) In the function? 2) Outside the function?. i initialy decided to put it inside the function since i call tis function from several places in the application, but after that i see that i needed to try...catch outside the function because if there is an error reloading the lists i want to disable some menues. so do i have tones of such error handling design questions

  • User profile image
    Ion Todirel

    I have a utility function that loads up lists in memory. lets call it RefreshList, if there is any error happening in this function i need to display a clear message like "Could not reload the lists, [Reason]" but where do i put the code to display the message 1) In the function? 2) Outside the function?. i initialy decided to put it inside the function since i call this function from several places in the application, but after that i see that i needed to try...catch outside the function because if there is an error reloading the lists i want to disable some menus (error handling). so do i have tones of such error handling design questions.

    http://www.awprofessional.com/articles/article.asp?p=102315&rl=1
    http://msdn2.microsoft.com/en-us/library/ms229014.aspx

  • User profile image
    Shrage

    Thanks, I have already read both articals but it dosn't give you real life examples of how to manage errors in shring wrapped application, most of the talk are relevent for custom applications, where you can send emails etc. it also talk more about the business layor of the applcation not the presentation layer of the application, which type of message to display for the user and what to log.

  • User profile image
    Cannot​Resolve​Symbol
  • User profile image
    blowdart

    Shrage wrote:
    Thanks, I have already read both articals but it dosn't give you real life examples of how to manage errors in shring wrapped application, most of the talk are relevent for custom applications, where you can send emails etc. it also talk more about the business layor of the applcation not the presentation layer of the application, which type of message to display for the user and what to log.


    You'll probably find it's a personal thing, or set as a company standard.

    For example I tend to have an "all in one" class that handles the display of the error messages, pulling the strings from the application resources, and logging in the event log, or other location as indicated in the app.config. If an exception is passed into it then it will add more> button to the error message which will expand out the exception in a nice tree structure. Of course the app wide unhandled exception event hooks into the same dialog, which is static, so there's not much worry about running out of memory when you try to display it

    The question about where to call it is more difficult. My gut feeling is the same as the attitude I have to exceptions, if you can handle the error, do so, display the message as soon as you code has the ability to cope.

  • User profile image
    DoomBringer

    Proper error handling: crash.

    For reals though, I usually end up writing a unified logging service for the whole app.  I'll admit, it does feel a bit tacked on, but nothing is perfect.

Conversation locked

This conversation has been locked by the site admins. No new comments can be made.