Questions related to handling errors and exceptions. According to Wikipedia, Exception handling is the process of responding to the occurrence, during computation, of exceptions – anomalous or exceptional events requiring special processing – often changing the normal flow of program execution. It ...

learn more… | top users | synonyms

53
votes
11answers
5k views

I've been told that Exceptions should only be used in exceptional cases. How do I know if my case is exceptional?

My specific case here is that the user can pass in a string into the application, the application parses it and assigns it to structured objects. Sometimes the user may type in something invalid. ...
0
votes
2answers
164 views

Custom error handling

I'm trying to figure out the best way to handle custom errors in my application. Option 1: if(expr) { } else { $_SESSION['error'] = "Some message describing the error"; } Option 2: if(expr) { ...
3
votes
1answer
165 views

Returning status code where one of many errors could have occured

I'm developing a PHP login component which includes functions to manipulate the User object, such as $User->changePassword(string $old, string $new) What I need some advice with is how to return a ...
0
votes
1answer
693 views

PHP MVC error handling, view display and user permissions

I am building a moderation panel from scratch in a MVC approach and a lot of questions cropped up during development. I would like to hear from others how they handle these situations. Error ...
2
votes
2answers
105 views

How does one handle an incorrect resource file?

I'm starting the parser that will handle one of the key features of my app and realizing exactly who easy it would be for me to screw up a resource file that is provided to the application. For ...
3
votes
3answers
138 views

handling a GET error properly

I have a website that takes two primary get strings: ?type=GAME&id=SomeGameID ?type=SCENARIO&id=SomeScenarioID for reasons unknown, I have recently begun receiving requests for erroneous ...
1
vote
4answers
173 views

What is the best way to go about testing that we handle failures appropriately?

we're working on error handling in an application. We try to have fairly good automated test coverage. One big problem though is that we don't really know of a way to test some of our error handling. ...
4
votes
1answer
158 views

Why is nesting or piggybacking errors within errors bad in general?

Why is nesting or piggybacking errors within errors bad in general? To me it seems bad intuitively, but I'm suspicious in that I cannot adequately articulate why it is bad. This may be because it is ...
40
votes
10answers
3k views

Why are exceptions considered better than explicit error testing? [duplicate]

Possible Duplicate: Defensive Programming vs Exception Handling? if/else statements or exceptions I often come across heated blog posts where the author uses the argument: "exceptions vs ...
33
votes
7answers
4k views

Should a stack trace be in the error message presented to the user?

I've got a bit of an argument at my workplace and I'm trying to figure out who is right, and what is the right thing to do. Context: an intranet web application that our customers use for accounting ...
2
votes
2answers
1k views

Should I represent special cases (like errors / exceptions) in UML diagrams?

Let's say you write a program that, when started, reads its configuration file to know which modules to start-up etc. If that configuration file is missing, an error will probably show up. This is an ...
81
votes
12answers
6k views

How big does my project need to be for me to unit test it? [closed]

I assume that my project is decoupled enough to allow for unit testing. But how big, exactly, in terms of clases and functions does my project need to be to make unit testing worthwhile? We all make ...
0
votes
1answer
1k views

Generic way of handling exceptions in windows phone? [closed]

I mean what are some of the ways other programmers deal with exception for example, when an error occurs when accessing a web service for say. If an example cant be given for windows phone, give the ...
1
vote
1answer
108 views

How I identify true error?

I am writing a program to scrap some data from the web. The pages are sequential ( 1,2,3 ... ), but I have no idea when will it stops. I combine a prefix and a integer to make a link for the python ...
2
votes
1answer
2k views

web server response code 500

I realize that this may spur a religious discussion, but I discussed this with friends and get great, but conflicting answers and the actual documentation is of little help. What does the 500 series ...
2
votes
3answers
903 views

Good practice or service for monitoring unhandled application errors for a small organization

I'm working with multiple software with varying ways of monitoring for errors. When I make software, I usually send email with the stack trace to admins(usually me). Some customer software is ...
13
votes
5answers
4k views

null pointers vs. Null Object Pattern

Attribution: This grew out of a related P.SE question My background is in C / C++, but I have worked a fair amount in Java and am currently coding C#. Because of my C background, checking passed and ...
61
votes
14answers
9k views

Should one check for null if he does not expect null?

Last week, we had a heated argument about handling nulls in our application's service layer. The question is in the .NET context, but it will be the same in Java and many other technologies. The ...
83
votes
10answers
10k views

The modern way to perform error handling…

I've been pondering this problem for a while now and find myself continually finding caveats and contradictions, so I'm hoping someone can produce a conclusion to the following: Favour exceptions ...
13
votes
5answers
14k views

try-catch in javascript… isn't it a good practice?

There is a provision for try-catch block in javascript. While in java or any other language it is mandatory to have error handling, I don't see anybody using them in javascript for greater extent. ...
8
votes
3answers
1k views

Different callbacks for error or error as first argument?

We (and the JS SO chat room) had a talk with @rlemon some days ago about his Little-XHR library about error handling. Basically, we wanted to decide which error handling pattern should be used: ...
1
vote
6answers
316 views

Catching an error?

Is catching an error with try ... catch a better practice than catching an error with proper analysis/error check? For instance, removing from an empty list: Does surround with a try catch clause ...
8
votes
8answers
1k views

Using a try-finally (without catch) vs enum-state validation

I have been reading the advice on this question about how an exception should be dealt with as close to where it is raised as possible. My dilemma on the best practice is whether one should use a ...
10
votes
4answers
5k views

Handling Errors In PHP When Using MVC

I've been using Codeigniter a lot recently, but one thing that gets on my nerves is handling errors and displaying them to the user. I've never been good at handling errors without it getting messy. ...
5
votes
2answers
241 views

Is error suppression acceptable in role of logic mechanism?

This came up in code review at work in context of PHP and @ operator. However I want to try keep this in more generic form, since few question about it I found on SO got bogged down in technical ...
9
votes
4answers
648 views

Recommend a design pattern/approach to exposing/tolerating/recovering from system errors, Exception handling (e.g.s in Java, C++, Perl, PHP)

Can you recommend a design pattern/approach to exposing/tolerating/recovering from system errors, Exception handling (Java, C++, Perl, PHP)? Some errors need to be reported. Some errors can be ...
21
votes
15answers
8k views

Arguments for or against using Try/Catch as logical operators [closed]

I just discovered some lovely code in our companies app that uses Try-Catch blocks as logical operators. Meaning, "do some code, if that throws this error, do this code, but if that throws this error ...
4
votes
2answers
562 views

Is there a term for the error-handling anti-pattern of discarding all available info and just returning failure?

From time to time (unfortunately way too often) I have to fix code such as this: // C++ code bool anyOldFunction(Param p) { try { ... if(some_condition_here) { handleErrorX(); return ...
30
votes
20answers
2k views

How do you tackle really bizarre errors that keep you puzzled for more than 10 hours? [closed]

You know them, those errors that make NO sense. Where it seems like a gremlin just jumped deep inside your chips and messed up something. Do you take a walk, write stuff, call an uncle? I need help!!
1
vote
1answer
171 views

How do you deal with errors in enumeration / list processing (lowish-level API)

Ive struggled with variants of this problem many times, experimenting with different solutions, happy with none. Abstract: Enumerating a list of items, an error for one item does not affect the ...
5
votes
3answers
539 views

How should a web API handle misspelled/extra parameters?

Question: For a public facing web API(send HTTP Get/Post requests, get JSON/XML data back), how should parameters be handled that are either misspelled or are extra. It seems to me that if the ...
20
votes
5answers
1k views

Is possible to write too many asserts?

I am a big fan of writing assert checks in C++ code as a way to catch cases during development that cannot possibly happen but do happen because of logic bugs in my program. This is a good practice in ...
6
votes
5answers
683 views

Checked vs Unchecked vs No Exception… A best practice of contrary beliefs

There are many requirements needed for a system to properly convey and handle exceptions. There are also many options for a language to choose from to implement the concept. Requirements for ...
10
votes
4answers
3k views

`trigger_error` vs `throw Exception` in the context of PHP's magic methods

I'm having a debate with a colleague over the correct usage (if any) of trigger_error in the context of magic methods. Firstly, I think that trigger_error should be avoided except for this one case. ...
3
votes
3answers
169 views

When should I decline to make a requested change?

I work on the software side of a company that provides custom hardware with software running on top of it. Often times the hardware is not engineered well. In those cases, I am often asked first to ...
7
votes
3answers
1k views

Page Not Found: 404 - the best content to put in this page [closed]

Do you let me know what kind of content I should put in the error-page like "404 page not found"? Example: "Unfortunately an error has occurred during the processing of your page request." "Page ...
2
votes
4answers
653 views

Should I achieve validation by handling errors in classic ASP?

I came across this while modifying an old ASP application: ON ERROR RESUME NEXT ivalue = CDATE(ivalue) IF err.number > 0 THEN ivalue = CDATE(date) END IF err.clear This doesn't look like ...
40
votes
2answers
16k views

What are the definitive guidelines for custom Error Handling in ASP.NET MVC 3?

The process of doing custom error handling in ASP.NET MVC (3 in this case) seems to be incredibly neglected. I've read through the various questions and answers here, on the web, help pages for ...
8
votes
3answers
1k views

Exceptions or Error codes

We are building a web service(SOAP, .Net) which would be talking to (mostly) native clients (windows, C++) and we are wondering what is the best way to communicate errors to the client (e.g. ...
5
votes
3answers
219 views

When you write wrappers for APIs how do you handle usage errors?

When you write wrappers for APIs how do you handle usage errors? Do you assume that the user uses it right and write the wrapper such that it makes the call to the server and let the server return ...