Click here to Skip to main content
15,895,799 members

Survey Results

Which of the following issues are best handled using Exceptions?

Survey period: 9 Feb 2015 to 16 Feb 2015

Exception handling provides a way to deal with any unexpected or exceptional situations. Define "unexpected".

OptionVotes% 
My bad code (null reference, divide by zero, index out of range etc)53645.85
Errors due to failed network connection70260.05
External Resource (eg webservice) not found or available66556.89
Backend server fails (eg internal database or cache server goes down)70560.31
Local resource access fails (eg can't open a file)63254.06
Timeout (database, file access, network connection)65556.03
Invalid parameter values36731.39
Invalid data supplied by the user30225.83
Respondents were allowed to choose more than one answer; totals may not add up to 100%



 
GeneralRe: Missing alternative. Pin
Cristian Amarie9-Feb-15 23:43
Cristian Amarie9-Feb-15 23:43 
GeneralThere are no exceptions Pin
Mike Hankey9-Feb-15 1:31
mveMike Hankey9-Feb-15 1:31 
GeneralRe: There are no exceptions Pin
CDP18029-Feb-15 1:54
CDP18029-Feb-15 1:54 
GeneralRe: There are no exceptions Pin
Mike Hankey9-Feb-15 1:58
mveMike Hankey9-Feb-15 1:58 
GeneralRe: There are no exceptions Pin
CDP18029-Feb-15 3:41
CDP18029-Feb-15 3:41 
GeneralRe: There are no exceptions Pin
Mike Hankey9-Feb-15 3:55
mveMike Hankey9-Feb-15 3:55 
GeneralRe: There are no exceptions Pin
Ștefan-Mihai MOGA9-Feb-15 1:58
professionalȘtefan-Mihai MOGA9-Feb-15 1:58 
GeneralAll errors are unexpected PinPopular
CDP18029-Feb-15 0:30
CDP18029-Feb-15 0:30 
If I had seen them coming, I would have handled this case before any exception would be raised. And when an exception comes, it will be logged. In most cases the current operation will also be aborted. Often the code to recover and continue after an error gets far more complicated than what it is worth.

The second and more important part is what you do with the log entries.

If the error is avoidable (like checking for null references), then you can turn the unexpected error into an expected and handled case. In the future there will be no more exceptions because of this.

In other cases you may be able to avoid the error by handling it in some way. You may, for example, wait a short time and retry a few times when a resource is temporarily blocked.

Last, there are the cases you can't do anything about. They are certainly unexpected. Why would you try to access something while expecting it not to work? Whatever has happened, it took place outside of your application and usually without prior notice. All you can do is to document the events in your log.

Proper testing can eliminate most of the first two types, leaving only the third. Exceptions are fine to assure that errors are logged and not swept under the rug. Then see to it that all errors appear only twice in the logs: For the first and the last time.

Only for the validation of user inputs I would use a more interactive approach than exceptions and logging. Smile | :) Actually, I don't see failed validation as an error. To me it's more a form of application logic that iterates over the user submitting input and validating it until it meets the requirements, whatever they may be. It's not unexpected, nor is this exceptional.
The language is JavaScript. that of Mordor, which I will not utter here

This is Javascript. If you put big wheels and a racing stripe on a golf cart, it's still a f***ing golf cart.

"I don't know, extraterrestrial?"
"You mean like from space?"
"No, from Canada."

GeneralAll but user input, but not all the time PinPopular
Rob Grainger8-Feb-15 23:36
Rob Grainger8-Feb-15 23:36 
GeneralDepends on the application Pin
RugbyLeague8-Feb-15 21:48
RugbyLeague8-Feb-15 21:48 
GeneralI always use exceptions... PinPopular
AlexCode8-Feb-15 21:32
professionalAlexCode8-Feb-15 21:32 
GeneralRe: I always use exceptions... Pin
Jan Holst Jensen210-Feb-15 1:42
Jan Holst Jensen210-Feb-15 1:42 
GeneralBit of a vague questions this week... PinPopular
OriginalGriff8-Feb-15 20:22
mveOriginalGriff8-Feb-15 20:22 
GeneralRe: Bit of a vague questions this week... Pin
Nicholas Marty9-Feb-15 1:15
professionalNicholas Marty9-Feb-15 1:15 
GeneralRe: Bit of a vague questions this week... Pin
Dan Neely9-Feb-15 3:18
Dan Neely9-Feb-15 3:18 
GeneralRe: Bit of a vague questions this week... Pin
Nicholas Marty9-Feb-15 3:37
professionalNicholas Marty9-Feb-15 3:37 

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.