Click here to Skip to main content

The Weird and The Wonderful

   

The Weird and The Wonderful forum is a place to post Coding Horrors, Worst Practices, and the occasional flash of brilliance.

We all come across code that simply boggles the mind. Lazy kludges, embarrasing mistakes, horrid workarounds and developers just not quite getting it. And then somedays we come across - or write - the truly sublime.

Post your Best, your worst, and your most interesting. But please - no programming questions . This forum is purely for amusement and discussions on code snippets. All actual programming questions will be removed.

 
GeneralRe: Something is not as I expected PinmemberAmitosh Swain20-Jun-13 22:32 
GeneralRe: Something is not as I expected PinmemberRob Grainger23-Jun-13 23:57 
GeneralRe: Something is not as I expected PinmemberMember 467320212-Jul-13 13:11 
GeneralEverywhere a single Catch block used catching top Exception all times. PinprofessionalMohammed Hameed19-Jun-13 20:28 
GeneralRe: Everywhere a single Catch block used catching top Exception all times. Pinmembercjb11019-Jun-13 21:13 
GeneralRe: Everywhere a single Catch block used catching top Exception all times. PinprofessionalMohammed Hameed19-Jun-13 21:20 
GeneralRe: Everywhere a single Catch block used catching top Exception all times. PinmemberRob Grainger24-Jun-13 0:02 
GeneralRe: Everywhere a single Catch block used catching top Exception all times. PinmemberJarek Kruza19-Jun-13 21:56 
The question is why do you catch exceptions at all... Wink | ;)
 
Most common answer is - to react to specific errors, for example - AccessDenied exception -> show message to user, SQLException - inform about DB problems or retry/abort and clean up..., etc.
 
In theory if application is properly writen, nothing unexpected should happen. But what if it happens?
 
You have two options:
 
1. Allow you OS/Framework show "unhandled exception" message - this annoys end users and makes troubleshooting harder as most users will close the window and will not report the details
2. Catch all otherwise unhandled exceptions and do something with them - log and rethrow or supress with generic error message and app shutdown/restart
 
Generally in development - this is not very good, unless you have a breakpoint in catch block or rethrow exception in debug config.
In production - I personally think this is good idea. For sure better than "unhandled exception" or empty catch block. Smile | :)
GeneralRe: Everywhere a single Catch block used catching top Exception all times. PinprofessionalMohammed Hameed19-Jun-13 22:08 
GeneralRe: Everywhere a single Catch block used catching top Exception all times. PinmemberJarek Kruza20-Jun-13 1:30 
GeneralRe: Everywhere a single Catch block used catching top Exception all times. PinmemberRob Grainger24-Jun-13 0:04 
GeneralRe: Everywhere a single Catch block used catching top Exception all times. PinprofessionalMohammed Hameed24-Jun-13 0:31 
GeneralRe: Everywhere a single Catch block used catching top Exception all times. PinmemberChris Ross 224-Jun-13 2:32 
GeneralRe: Everywhere a single Catch block used catching top Exception all times. PinmemberRob Grainger24-Jun-13 4:08 
GeneralRe: Everywhere a single Catch block used catching top Exception all times. PinprofessionalV.19-Jun-13 23:25 
GeneralRe: Everywhere a single Catch block used catching top Exception all times. PinprofessionalMohammed Hameed19-Jun-13 23:56 
GeneralRe: Everywhere a single Catch block used catching top Exception all times. Pinmembercjb11020-Jun-13 0:12 
GeneralRe: Everywhere a single Catch block used catching top Exception all times. PinprofessionalMohammed Hameed20-Jun-13 0:26 
GeneralRe: Everywhere a single Catch block used catching top Exception all times. PinprofessionalV.20-Jun-13 0:31 
GeneralRe: Everywhere a single Catch block used catching top Exception all times. PinprofessionalMohammed Hameed20-Jun-13 1:11 
GeneralRe: Everywhere a single Catch block used catching top Exception all times. PinprofessionalRichard Deeming20-Jun-13 1:36 
GeneralRe: Everywhere a single Catch block used catching top Exception all times. PinprofessionalV.20-Jun-13 1:39 
GeneralRe: Everywhere a single Catch block used catching top Exception all times. PinmemberAnalogNerd24-Jun-13 2:26 
GeneralRe: Everywhere a single Catch block used catching top Exception all times. PinprofessionalMohammed Hameed24-Jun-13 2:37 
GeneralRelational database reinvented as a flat file... Pinmemberjohnsyd19-Jun-13 19:58 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.


Advertise | Privacy | Mobile
Web01 | 2.8.140721.1 | Last Updated 31 Jul 2014
Copyright © CodeProject, 1999-2014
All Rights Reserved. Terms of Service
Layout: fixed | fluid