Date: Sun, 30 Aug 2026 15:27:47 +0200
In practice there seem to be 4 ways how modern programming-languages handle exceptions.
The need to sometimes propagate the errors up the call hierarchy is addressed.
Sometimes possible exceptions are marked, sometimes not, sometimes both options are offered.
Sometimes the call site, which can lead to an exception, is marked, sometimes not.
1. C++ exceptions / Java unchecked exceptions
==================================
- Automatically propagate up the call stack
- Caller does *not* have to mark at call site
- Individual exceptions do *not* have to be listed in signature
- In C++ function signature does not contain noexcept
2. Java checked exceptions
====================
- Automatically propagate up the call stack
- Caller does *not* have to mark at call site
- Individual exceptions *must* be listed in signature
3. Swift throw
==========
- Propagate up the call stack
- Caller has to mark with try
- Individual exceptions do *not* have to be listed in signature for untyped exceptions (function signature contains throw)
- Individual exceptions *must* be listed in signature for typed exceptions
4. Zig try, Rust ?, Go error, C++ expected
==============================
- Similar to 3., but error is part of return value
- Compiler may warn/error, if return value is discarded
- Has to be explicitly rethrown
- Some languages offer operator to explicitly propagate
Received on 2026-08-30 13:34:02
