Home > Return Code > The Exception That Grounded An Airline

The Exception That Grounded An Airline


That creates a object to object dependency, which breaks the rule of encapsulation. I wouldn't hire anyone that used goto's, or returned error values. Does it throw a structured exception? Need a better layout, so that blank space can be utilized Why is my scene rendered repeatedly when I press F12?

I believe return codes have a place when failure is commonplace. –Steve Dec 4 '09 at 20:47 add a comment| up vote 3 down vote As a general rule. When an exception occurs in layer A it may only be of concern to layer C. NUKE The problem with exception is that overusing them will produce code full of try/catches. What is better in my opinion: exceptions > error codes (non-local error handling) error handlers > exceptions (won't unwind stack) error codes > error handlers (speed & simplicity) That's the issue

The Exception That Grounded An Airline

You can skip writing the bad code at all, and do all your failure handling via RAII. share|improve this answer answered Sep 19 '08 at 4:50 Jason Etheridge 4,58552230 1 Remember that using exceptions makes program analysis harder. –Paweł Hajdan Sep 19 '08 at 9:17 add a C++ exceptions are worse than useless. So, you're going to throw an exception, huh?

Create specific RuntimeException child classesSo, finally, we could end up with one specific exception for each exceptional situation, something like:PHP class InvalidLoginCredentialsException extends \RuntimeException { }123class InvalidLoginCredentialsException extends \RuntimeException{}PHP class TooManyLoginAttemptsException extends Both are prone to it, and both will fail in similar ways. Consider this: I have a worker which pops an element from a queue. Exception Error Code Java Without an example of some code that would cause this, it seems like this is another scarecrow like "performance": a canard people cook up as an excuse to avoid exceptions. #15

OK, then I guess. –uh oh somebody needs a pupper Jun 13 at 12:18 1 @freakish I'd separate the functions into two bits: one that returns a bool called try_whatever Java Throw Exception And Return Value As to his first argument, I agree with Ned and one of the previous posters. Special operations on a list Why does rotation occur? Doing so, exceptions prevent to do some extra work while in a incoorect state, and thus prevent to potentially damage more data.

I am saying that if you could afford to wait for something for 15 minutes, then if it doesn't arrive after 15 minutes (no matter if that happens 1% or 99% Joel On Software Exceptions And Try-catch where you actually catch an exception you're able to handle is good, or if you do this: try{ db.UpdateAll(somevalue); } catch (Exception ex) { logger.Exception(ex, "UpdateAll method failed"); throw; In how many bits do I fit Does Ohm's law hold in space? Exceptions are used by most other modern languages.

Java Throw Exception And Return Value

share|improve this answer answered Sep 19 '08 at 5:02 Kendall Helmstetter Gelner 65.1k24109132 add a comment| up vote 1 down vote I don't find return codes to be less ugly than Exceptions already come with richer information (there's a section in the article about this). The Exception That Grounded An Airline For example, C may know how to handle it, while B can't. C++ Error Codes Vs Exceptions As for throwing exception on non-existing files.

We use an application where I work that won't even let you type in the file type for a report's output file. In my opinion, the best discussion on exceptions starts with Tom Cargill's "Exception Handling: A False Sense of Security". It's possible to collect an "error code call stack" with all the information, but it's almost never done. Exceptions are for exceptional errors - the ones that aren't supposed to happen, but might do so once in a blue moon. C++ Exceptions Vs Return Codes

So all of those possible exit points for a function are still possible exit points, but you have to check the status returns explicitly, and return from the function. I just wanted to point out that your comment ('This tells me everything I need to know about the depth of your argument') is by no means a deep argument in Ed Smits #33 j5c on 09.26.12 at 1:15 am Exceptions and error codes should be two different animals. rs 9:06 AM on 18 Mar 2010 You are not helping by highlighting google search terms, only making it more annoying until I reload the page.

C++ has RAII for the gate-closing (and Python has with and C# has using), and Java has checked exceptions for the exception-hunting. C++ Exceptions Best Practices Going with this approach, would put an extra requirement on the types that can be used with your BlockingQueue: they must be default constructible. However, if a call to create an entry in a table fails because of a unique constraint as a result of a value entered by a user the only entity that

share|improve this answer answered Dec 4 '09 at 20:37 JaredPar 463k889351246 I can certainly ignore an exception, just don't handle it.

Related 305When to throw an exception?1331Catch multiple exceptions at once?369Should a retrieval method return 'null' or throw an exception when it can't produce the return value?382What should main() return in C Error codes can be OK, but returning 404 or 200 from a method is bad, IMO. In other words "only use exceptions for exceptional things". –Paweł Hajdan Sep 19 '08 at 9:18 add a comment| up vote 2 down vote I prefer to use exceptions for error Raii Not the answer you're looking for?

I agree that almost all C++ code needn't worry about the cost of exceptions, but comparing them against the timeout doesn't capture why: it has to be because they're cheap compared Both are negligible individually, but the difference will show up in high numbers. –uh oh somebody needs a pupper Jun 13 at 13:03 But those "high" numbers will be Linked 2 which is better, throw an exception or return nonzero value? 0 Exception or Error Messages 74 Why should exceptions be used conservatively? 23 Exceptions and error codes: mixing them So you use them only for programmer errors, which you can't fix by using error codes anyway.

share|improve this answer edited Dec 4 '09 at 20:56 answered Dec 4 '09 at 20:43 Doug T. 41.6k1694167 Additionally, exceptions have been shown when I have measured them to This goes back to not being able to ignore it silently, it requires work –JaredPar Dec 5 '09 at 18:15 | show 1 more comment up vote 3 down vote Faster Corrupt memory, broken hardware, etc. I need to think about their points. –Steve Dec 4 '09 at 20:46 3 It may be true that writing exception-safe code is hard, but writing correct code that relies

Something we could solve extracting it to a constant as we've done with the magic number, but since it is a specific situation in this point of the example, I prefer to Usually, "doSomething()" or "doSomethingElse()" actually perform something, like changing a state of some object. Second, it isn't hard to write exception-safe code once you've learned how to do it. Best understood when you have faced some disasters yourself ;-) My point: someone without experience will probably not comprehend the truth of this article.

As I state; the using pattern should be used (doh!) if available. Now I see what you mean… But if they end up unwinding the stack - the ability where their extra power is compared to error callbacks - then I think "restart Use the one that fits better and you'll be better off than anyone that thinks one is always better. I must say that based on my experience I fully agree with Joel.