Click here to Skip to main content
15,905,558 members

Survey Results

How do you return error conditions?   [Edit]

Survey period: 16 Apr 2007 to 22 Apr 2007

If a routine encounters an error do you hope the caller checks, or do you throw an exception to force the point? (inspired by Anna's blog)

Q1. For non-critical errors:

OptionVotes% 
Set a global error flag222.40
Return a reserved value (0 or -1 etc)27830.32
Return an encoded error value (eg HRESULT)14716.03
Throw an exception37340.68
Cover up the mess and don't say anything9710.58

View optional text answers (23 answers)
Q2. For critical errors that leave the app in an undefined state

OptionVotes% 
Set a global error flag444.80
Return a reserved value (0 or -1 etc)566.11
Return an encoded error value (eg HRESULT)626.76
Throw an exception69776.01
Cover up the mess and don't say anything505.45

View optional text answers (26 answers)


 
GeneralEnum for non-critical error Pin
Jcmorin19-Apr-07 4:18
Jcmorin19-Apr-07 4:18 
JokeTell the user... Pin
Jeremy Falcon19-Apr-07 0:08
professionalJeremy Falcon19-Apr-07 0:08 
GeneralRe: Tell the user... Pin
Paul Conrad22-Apr-07 10:08
professionalPaul Conrad22-Apr-07 10:08 
GeneralThe fifth option is doing well!! Pin
Nibu babu thomas18-Apr-07 2:37
Nibu babu thomas18-Apr-07 2:37 
JokeAutomatic firing of responsible developer Pin
Ashley van Gerven17-Apr-07 0:51
Ashley van Gerven17-Apr-07 0:51 
GeneralYeaaaaaaassss ! Pin
Kochise17-Apr-07 2:00
Kochise17-Apr-07 2:00 
GeneralRe: Yeaaaaaaassss ! Pin
StevenWalsh18-Apr-07 3:13
StevenWalsh18-Apr-07 3:13 
GeneralRe: Automatic firing of responsible developer Pin
Corinna John18-Apr-07 7:37
Corinna John18-Apr-07 7:37 
GeneralRe: Automatic firing of responsible developer Pin
Kochise18-Apr-07 21:36
Kochise18-Apr-07 21:36 
GeneralRe: Automatic firing of responsible developer Pin
ThatsAlok20-Apr-07 20:58
ThatsAlok20-Apr-07 20:58 
GeneralAnnas blog and Likely{T} Pin
peterchen16-Apr-07 23:46
peterchen16-Apr-07 23:46 
GeneralRe: Annas blog and Likely{T} Pin
Andre xxxxxxx20-May-07 3:25
Andre xxxxxxx20-May-07 3:25 
GeneralClaim it's Windows' fault ! Pin
Kochise16-Apr-07 21:52
Kochise16-Apr-07 21:52 
GeneralTry and Recover, Otherwise Die and Leave a Suicide Note Pin
Ri Qen-Sin16-Apr-07 8:33
Ri Qen-Sin16-Apr-07 8:33 
GeneralRe: Try and Recover, Otherwise Die and Leave a Suicide Note Pin
Almighty Bob16-Apr-07 11:43
Almighty Bob16-Apr-07 11:43 
GeneralCString Pin
bob1697216-Apr-07 5:27
bob1697216-Apr-07 5:27 
GeneralRe: CString Pin
Nemanja Trifunovic17-Apr-07 9:04
Nemanja Trifunovic17-Apr-07 9:04 
GeneralRe: CString Pin
bob1697217-Apr-07 10:26
bob1697217-Apr-07 10:26 
GeneralRe: CString Pin
StevenWalsh18-Apr-07 3:16
StevenWalsh18-Apr-07 3:16 
GeneralRe: CString Pin
ThatsAlok20-Apr-07 21:00
ThatsAlok20-Apr-07 21:00 
GeneralExceptions are good Pin
Gary Wheeler16-Apr-07 2:33
Gary Wheeler16-Apr-07 2:33 
GeneralRe: Exceptions are good Pin
bob1697216-Apr-07 5:22
bob1697216-Apr-07 5:22 
Gary Wheeler wrote:
I use MSXML


That happens to be to be the item that got me to finally appreciate how much effort an exception can save me with deep nesting. Put the try at the top level of the dom walker and let it go.

Elsewhere, though I've found little use for them but I'm sure I'll find another someday. Exceptions are definitely not as common in my code and more of a nuisance in general.
General...unless you are using C++ Pin
peterchen16-Apr-07 10:21
peterchen16-Apr-07 10:21 
GeneralRe: ...unless you are using C++ Pin
Nemanja Trifunovic16-Apr-07 13:34
Nemanja Trifunovic16-Apr-07 13:34 
GeneralRe: ...unless you are using C++ Pin
peterchen16-Apr-07 21:45
peterchen16-Apr-07 21:45 

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

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