Fatal Errors
A fatal error aborts the program on an unrecoverable condition rather than returning an error to the caller. Fatal errors are reserved for bugs and invariant violations — situations the program is not expected to handle at runtime.
You can trigger one explicitly with Fatal from the Std package, which prints a diagnostic message and the call-site location to standard error and exits with code 1:
rux
import Std::Fatal;
Fatal("unreachable: unknown variant");Several documented operations also fail fatally:
- Integer overflow in debug builds raises a fatal error; release builds wrap instead (see Signed Integer overflow behaviour).
- Narrowing character casts raise a fatal error when the value is out of range; use
as?to getnullinstead (see Character Types). - Casting
NaNorInfto an integer raises a fatal error in debug builds (see Floating-Point Types).
For conditions a caller is expected to recover from, return a Result instead.
See Also
- The
ResultType — the recoverable-error alternative Fatal— the standard-library function that triggers a fatal error- Intrinsic Constants — the
#file/#linevalues reported at the call site