An exception is an occurrence in an application process that requires deviation from the program's normal flow.

learn more… | top users | synonyms

13
votes
7answers
907 views

Do exceptions basically exist to prevent a system from crashing?

Second of all, I was wondering if anyone knew what the difference was between exceptions (in the realm of exception control flow) and Exceptions (such as used in Java). But are they there to ...
21
votes
3answers
5k views

Why are exception specifications bad?

Back in school some 10+ years ago, they were teaching you to use exception specifiers. Since my background is as one of them Torvaldish C programmers who stubbornly avoids C++ unless forced to, I only ...
2
votes
1answer
78 views

What are possible/useful implementations when extending exceptions?

I have seen a lot of exceptions - custom or integrated in the language (PHP) itself that have no differences but their class name. When extending default exceptions to use within your own code, are ...
20
votes
4answers
5k views

Why do iterators in Python raise an exception?

Here's the syntax for iterators in Java (somewhat similar syntax in C#): Iterator it = sequence.iterator(); while (it.hasNext()) { System.out.println(it.next()); } Which makes sense. Here's ...
3
votes
2answers
433 views

Why do interrupts need to be turned off when inside other interrupt code?

Simple question that will help me understand my OS class... thanks! Basically, why is it unsafe to have an interrupt within an interrupt? (or exception within exception)
3
votes
2answers
168 views

How to handle fired listeners exceptions

This is more of a design question and i was hoping to get pros and opinions on what makes sense. BACKGROUND Imagine something that holds one or more event listeners. Every now and then the thing ...
4
votes
2answers
488 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 ...
7
votes
3answers
3k views

Should I use try catch in my test methods?

I am doing unit testing. I am trying to test one function. I call it from my test component. But If remote function cannot handle the exception then my tester component will also get exception, I ...
10
votes
4answers
1k views

Do you throw an argumentexception or argumentnullexception from private methods?

I was just reviewing some code I wrote a while back, and can see that I have a couple of private methods that throw argumentnullexceptions and/or argumentexceptions if there are issues with the ...
8
votes
4answers
554 views

Is exception handling a cross-cutting concern?

I don't see much of a difference between the concerns of exception handling and logging in that both are cross cutting concerns. What do you think? Shouldn't it be handled separately on its own rather ...
11
votes
3answers
1k views

How did the idea of Exception-handling emerge into programming languages? [duplicate]

Possible Duplicate: Who designed exceptions? Today if we look at any language, exception handling is almost a compulsory feature. The languages that didn't have it earlier are implementing ...
6
votes
5answers
3k views

Is it not a good practice to handle runtime exceptions in the code?

I am working on a Java application, and I see that Run time exceptions are handled in many places. For example, try { //do something }catch(NullPointerException e){ ...
21
votes
8answers
4k views

What to put in a try/catch? [duplicate]

Note on the question: this is not a duplicate, Efficient try / catch block usage? was asked after this one. The other question is the duplicate. I was wondering what was the best way to use ...
4
votes
2answers
511 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 ...
19
votes
13answers
2k views

Why are null references shunned while throwing exceptions is considered okay?

I don't quite understand the consistent bashing of null references by some programming language folks. What's so bad about them? If I request read access to a file that doesn't exist then I'm ...
12
votes
4answers
2k views

Good use of try catch-blocks?

I always find myself wrestling with this... trying to find the right balance between try/catching and the code not becoming this obscene mess of tabs, brackets, and exceptions being thrown back up ...
4
votes
3answers
445 views

Improving exception handling? [duplicate]

I am a newbie programmer and I recently started learning about exception handling in Java. I know what try, catch and finally blocks do, but I really need to understand how to use them well and where ...
9
votes
4answers
4k views

How to simulate events that cause exceptions to test try/catch blocks?

I understand how exceptions work and how to catch and handle them in C# but how can I simulate events that may cause an exception to ensure that it is caught correctly? For example, is it possible to ...
21
votes
2answers
1k views

Who designed exceptions?

Where did exceptions and exception handling come from? I like how .NET uses it, I like how C++ supports it (but libraries unfortunately use return code or is written in C instead). I know its pretty ...
1
vote
1answer
338 views

How does compiler handle exceptions that are implicit? Looking for design strategies

Throughout the function handleException, the exception encountered is implicit. How does the compiler handle such implicit passing of exceptions? [For e.g. in C++ methods, this pointer is passed to ...
25
votes
12answers
1k views

What are developer's problems with helpful error messages? [closed]

It continue to astounds me that, in this day and age, products that have years of use under their belt, built by teams of professionals, still to this day - fail to provide helpful error messages to ...
36
votes
4answers
2k views

How to write a good exception message

I'm currently doing a code review and one of the things I'm noticing are the number of exceptions where the exception message just seems to reiterate where the exception occurred. e.g. throw new ...
6
votes
4answers
134 views

Do you have any teamguidelines regarding exceptions?

My team recently inherited a project from a team where the amount of developers dropped so low they had to offload some work. One of the projects we inherited was a project littered with nested code, ...
2
votes
1answer
56 views

Error handling, creating time line, need help defining what aspects of the environment need tracking

For my final year project, I'm working on a script that will run your python program and provide a time line of events(so far working on assignments) and create a story of what happened(the changes in ...
10
votes
1answer
3k views

Why does Java exit with success after an uncaught exception?

Any time a Perl, Python, C++ or Tcl program halts with an unhandled exception, those language runtimes take care to register a non-zero exit code for the process. Even Eclipse-based programs return 1 ...
12
votes
6answers
1k views

What's the best way to manage error logging for exceptions?

Introduction If an error occurs on a website or system, it is of course useful to log it, and show the user a polite message with a reference code for the error. And if you have lots of systems, you ...
8
votes
5answers
540 views

How much redundancy/robustness should complex software implement?

The focus of this question: Some software performs "extra work" in order to increase the chance of a "eventually successful/satisfactory" outcome, despite one or more internal errors in the software, ...
13
votes
8answers
2k views

In Java, what are checked exceptions good for?

Java's checked exceptions have gotten some bad press over the years. A telling sign is that it's literally the only language in the world that has them (not even other JVM languages like Groovy and ...
34
votes
20answers
4k views

Is it ever ok to have an empty catch statement?

I thought about it and could not come up with an example. Why would somebody want to catch an exception and do nothing about it? Can you give an example? Maybe it is just something that should never ...
7
votes
6answers
1k views

Is throwing an exception from a property bad form?

I've always been of the mindset that properties (ie, their set/get operations) should be fast/immediate and failure-free. You should never have to try/catch around getting or setting a property. But ...
7
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. ...
13
votes
4answers
710 views

Using assertions versus throwing exceptions?

Often when I write a functions I want to make sure the inputs to it are valid in order to detect such errors as early as possible (I believe these are called preconditions). When a precondition fails, ...
11
votes
5answers
635 views

When to start writing Exception Handling, Logging

When do you start writing your Exception Handling Code? When do you start writing Logging Statements. For the purpose of elaborating this question, let us assume that we are on .NET platform with ...
19
votes
12answers
2k views

How to teach Exception Handling for New Programmers?

How do you go about teaching Exception Handling to Programmers. All other things are taught easily - Data Structures, ASP.NET, WinForms, WPF, WCF - you name it, everything can be taught easily. With ...
55
votes
18answers
6k views

Are null references really a bad thing?

I've heard it said that the inclusion of null references in programming languages is the "billion dollar mistake". But why? Sure, they can cause NullReferenceExceptions, but so what? Any element of ...
7
votes
6answers
2k views

Do you handle Out-Of-Memory conditions?

What do you do when malloc returns 0 or new throws exception? Just halt or try to survive OOM condition/save the user's work?
4
votes
2answers
345 views

How much logging should I do at production for SQLExcpetions?

I'm writing a small database-centric application in Java Swing that will be used internally in a small company. I haven't much experience with developing production-level applications. I don't use an ...
10
votes
2answers
190 views

What would be the best way to handle errors in parallel programs?

With parallel algorithms knocking at the door, it might be a good time to think about error handling. So at first there were error codes. Those sucked. It was free to ignore them, so you could fail ...
6
votes
13answers
2k views

Should integer divide by zero halt execution? [closed]

I know that modern languages handle integer divide by zero as an error just like the hardware does, but what if we could design a whole new language? Ignoring existing hardware, what should a ...