Re: Problems Handling Errors Correctly

Tech Tip: Click here to run a free scan for Windows Errors and optimize PC performance



Jonathan Wood 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.

That's not a good idea, IMHO.

I never put exception handlers around code except when: a) I can recover gracefully from the exception and want to, and b) it's something that is known to be able to throw an exception.

If you are putting an exception handling block in every routine, you are doing WAY too much work.

Lots of methods are documented as being able to throw exceptions, but in many cases these exceptions are only thrown when you fail to call the method correctly in the first place. Rather than spending your time writing exception handling code for those methods, you should spend your time ensuring that you are calling the method correctly so that it won't throw an exception.

Pete
.



Relevant Pages

  • Re: count2.asm
    ... >> But seriously, without HLA's exception handling, it would have ... routine both end up checking for errors...the called routine checks for ... "general purpose handler" with catch the serious errors...if you want to ...
    (alt.lang.asm)
  • Re: x64 XP BSOD on USB device reset or D3 entry
    ... Have you tried running the test with driver verifier with special pool ... I did not assign any cleanup routine to any KMDF object. ... The completion routine only deletes objects that were allocated to ... The exception code that was not handled ...
    (microsoft.public.development.device.drivers)
  • Re: x64 XP BSOD on USB device reset or D3 entry
    ... Turning on the WDF verifier stopped the BSODs due to this problem. ... I did not assign any cleanup routine to any KMDF object. ... I'm porting an i386 XP KMDF USB device driver to x64 XP SP2. ... The exception code that was not handled ...
    (microsoft.public.development.device.drivers)
  • Re: Exception handling
    ... If you are dealing with input validation, you would code exception first, as you might as well throw out items that will not make it through the routine. ... The reason is you do not end up taking sloppy short cuts to get through the routine. ... It took a lot of discipline, but I found it led to lots of sloppy code, where I kept testing the same cases over and over again at each section of the routine. ...
    (microsoft.public.dotnet.languages.csharp)
  • Dynamic Enumeration Problem
    ... I'm enumerating child devices ... In DPC routine i had called the routine Bus_PlugInDeviceas ... The exception code that was not handled ... handler, status 0xc00000bb ...
    (microsoft.public.development.device.drivers)