Program logic bugs vs input/environmental errors (checked exceptions)
Jacob Carlborg via Digitalmars-d
digitalmars-d at puremagic.com
Mon Oct 6 11:13:38 PDT 2014
On 2014-10-06 18:03, Regan Heath wrote:
> Why?
>
> It gives us the benefits of error code return values:
> - ability to easily/cheaply check for/compare them using "switch" on
> code value (vs comparing/casting types)
> - ability to pass through OS level codes directly
>
> Without any of the penalties:
> - checking for them after every call.
> - losing the return value "slot" or having to engineer multiple return
> values in the language.
> - having to mix error codes in with valid return values (for int()
> functions).
>
> We also get:
> - no type proliferation.
> - no arguments about what exception types are needed, or the hierarchy
> to put them in.
>
> Seems like a win to me.
Then you'll always catch all exceptions. If error code doesn't match you
need to rethrow the exception. Or make a language change that allows to
catch based on the error code.
--
/Jacob Carlborg
More information about the Digitalmars-d
mailing list