Alternatives to exceptions for error handling
Ola Fosheim Grostad
ola.fosheim.grostad at gmail.com
Sun Nov 29 18:46:22 UTC 2020
On Sunday, 29 November 2020 at 18:17:02 UTC, Roman Kashitsyn
wrote:
> Thoughtful error handling never looks good, and exceptions
> don't help with that at all: try/catch syntax is very
> heavyweight and encourages you to propagate errors instead of
> dealing with them where they arise.
I have no proble with the syntax, but single inheritance is not
so great.
One should be able to throw and catch a set of properties in some
kind of pattern matching way. Maybe also inject handlers that are
triggered by certain patterns at certain boundaries.
> Exceptions also make type signatures less precise: it's hard to
> be sure I handled all the errors I can recover from if I don't
> know which errors can actually occur. There is no way to tell
> without inspecting the full transitive closure of the code I
> call into.
A good IDE should show this, so a tooling issue, not a language
issue.
More information about the Digitalmars-d
mailing list