http://qs1969.pair.com?node_id=863592


in reply to Re^9: eval to replace die?
in thread eval to replace die?

Chromatic suggested that using exceptions avoided "unreliable string comaprisons, substring comparisons and regexes". Which it doesn't. It just moves them.

Yes it does. It's not the string comparisons and regular expression matches that are unreliable. It's the process of determining the type of an error by the representation of it (the message).

For example, if you check if the error starts with "Foo", I will break your exception handling by throwing any error that starts with "Foo". That can't happen if the type of the error is carried externally to the representation shown to the user. And an object with a class is just that kind of an error. If you throw a MyError::Foo, I would have to explicitly throw that error or a subclass of it for it to be recognised by your error handling.

Handling errors by message inspection works fine as long as you're the only developer in the code base. And never upgrade.


Ordinary morality is for ordinary people. -- Aleister Crowley