Re: Problems Handling Errors Correctly

Tech-Archive recommends: Speed Up your PC by fixing your registry



On Sep 17, 12:04 am, "Jonathan Wood" <jw...@xxxxxxxxxxxxxxxx> wrote:

Yeah, the bottom line is that I don't particularly care for try...catch
exceptions. It gets to where you put try...catch in every routine if you
want to ensure you're program will never crash with an unhandled exception.

To me, exceptions are just that: "exceptional cases that should not
occur in normal usage" I treat them as "I fu*ked something up
somewhere". If I get an exception (unhandled or otherwise) I try to
fix the underlying CAUSE of the exception, whether it be due to
invalid arguments to a function or openning a nonexistent file. There
are some cases that I can think of that would have been more
convenient to return an error status than throw an exception (remoting
servers not available comes to mind <g>) back to me, but those are the
cases where I trap an exception in my code so that I can provide
graceful recovery/retry/feedback (a user isn't going to want to see
"SocketException" when trying to connect to a server when the network
is down...). General top level exception handlers are, to me, a bad
thing, because they tend to hide the underlying cause of problems from
the programmer.


You can still gracefully exit from unhandled exceptions: Add the
appropriate delegate to the AppDomain.CurrentDomain.UnhandledException
event and (for WinForms code) one to the Application.ThreadException
event. This way you can gracefully exit from/display/log any
exceptions that your code would not otherwise handle.

.



Relevant Pages

  • [NT] PNG (Portable Network Graphics) Deflate Heap Corruption Vulnerability (Windows)
    ... Beyond Security would like to welcome Tiscali World Online ... exception filter, overwriting the pointer to the handler with the address ... is set to the address of the unhandled exception filter hook. ...
    (Securiteam)
  • Function names for managed callstack under SOS debugging of .NET 2.0 app
    ... wrote that sets the unhandled exception filter ... unhandled exception filter, and we generate a mini-dump. ... The callstack above happens ...
    (microsoft.public.vsnet.debugging)
  • Re: Session StageVariables
    ... I did read an article about these Unhandle Exceptions that said go to VS Options Debugging\General and uncheck Enable Just My Code, this keeps the Unhandled exception from happening when in Debug mode, but is this just masking the problem? ... So look if you have a worker threads and enclose them into try.. ... We have a base page that gets called on every page and checks for session variables. ...
    (microsoft.public.dotnet.framework.aspnet)
  • Re: Exceptions Thrown in Background Threads
    ... The only time where it is not practical is when the exception actually ... ought not to be in a UE handler. ... One of the fields in the unhandled exception ... app immediately thereafter - the app has no control over this. ...
    (microsoft.public.dotnet.languages.csharp)
  • Re: SEHException at app startup
    ... Droopy wrote in ... I have the same exception with this previous version so it ... > legacy code but I am not sure this is the reason why the problem ... > Unhandled exception at 0x77f410a2 in IPRRouting.exe: 0xC0000008: Un ...
    (microsoft.public.dotnet.languages.csharp)