Click here to Skip to main content
15,908,254 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)


 
GeneralExceptions are evil Pin
Michael Dunn15-Apr-07 18:30
sitebuilderMichael Dunn15-Apr-07 18:30 
Generallongjmp() all the way! Pin
Shog915-Apr-07 19:12
sitebuilderShog915-Apr-07 19:12 
GeneralRe: longjmp() all the way! Pin
Gary Wheeler16-Apr-07 2:24
Gary Wheeler16-Apr-07 2:24 
GeneralRe: longjmp() all the way! Pin
John R. Shaw16-Apr-07 7:11
John R. Shaw16-Apr-07 7:11 
GeneralRe: longjmp() all the way! Pin
Gevorg17-Apr-07 5:37
Gevorg17-Apr-07 5:37 
GeneralRe: longjmp() all the way! Pin
Shog917-Apr-07 5:52
sitebuilderShog917-Apr-07 5:52 
GeneralRe: Exceptions are evil Pin
Nemanja Trifunovic16-Apr-07 2:01
Nemanja Trifunovic16-Apr-07 2:01 
GeneralEvent log Pin
Nisamudheen15-Apr-07 18:14
Nisamudheen15-Apr-07 18:14 
Generally and especially for critical errors I prefer logging a clear-cut message to the event log in addition to returning a predefined error code.



"Silence will create respect and dignity; justice and fair play will bring more friends;
benevolence and charity will enhance prestige and position; courtesy will draw benevolence;
service of mankind will secure leadership and good words will overcome powerful enemies"
Ali (Peace be upon him)

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.