Re: Tasty exceptions



Craig Stuntz [TeamB] wrote:
<snip>
generally speaking I see no advantage of turning an exception into an
error code in terms of a function result (as opposed to logging), and
you still must abort through one means or another. I think people tend
to do this when they haven't thought their call stack through carefully.


Generally, I can see 2 advantages to turning an exception into an error code:

1) To suppress useless exceptions.
Sometimes all you want to know is if something succeeded or failed.
In this case, you could really care less what the exception was and you still want
your programs execution to proceed.

2) Sometimes one can respond more efficiently to an error code using a case or an if statement
instead of using an exception handler.


The point is this: When a contract has been violated, your objects are
in an undefined state. That's dangerous.

An object can be in a defined state while dealing with all local exceptions locally.
That wouldn't be dangerous.
.



Relevant Pages

  • Re: Structured exception information
    ... Doesn't feel as type-safe as advertised. ... What, _exactly_, will the handler do with the separate bits? ... Looking up the localized error message in the dictionary based on the *type-safe* error code that it got from the exception object, ... I'm looking forward to see a convincing solution for error code and the dictionary. ...
    (comp.lang.ada)
  • Re: Exception : an ugly grammer in programming
    ... machinism in programming languages. ... we return error code when we meet an error. ... But how about use exception in OOP? ... Exceptions originally were designed to handle unexpected conditions, ...
    (comp.lang.php)
  • Exception : an ugly grammer in programming
    ... Yes, I'm doing PHP. ... machinism in programming languages. ... we return error code when we meet an error. ... But how about use exception in OOP? ...
    (comp.lang.php)
  • Re: [PHP] Re: MySQL exceptions
    ... I don't think MySQL or even mysqli have any kind of exception throwing ... echo "Impossible connect to server."; ... completely before trying to use a dead connection. ... error code number would be encapsulated as an ...
    (php.general)
  • Re: Structured exception information
    ... A real example is a HTTP component that reports error code with value 404 and the GUI leyer that looks up the dictionary of messages for currently selected language to resolve it to whatever is appropriate for display. ... You can argue that return code instead of exception might do the job and that's true - but then we are back to the discussion of return codes vs. exceptions, which is a paradigm issue - which should be independent on the technical abilities of each solution. ...
    (comp.lang.ada)