registerFatalError<T extends Object> static method
Registers errors of type T as fatal to Either error capture.
An error matching T, including any subtype of T, remains an error with
its original stack trace instead of being passed to an ErrorMapper and
converted to a Left.
This policy applies to Either.tryCatch, Either.tryCatchAsync, ToEitherFutureExtension.toEitherFuture, and ToEitherStreamExtension.toEitherStream.
Each Dart isolate keeps its own registry. Registering T in one isolate
does not affect other isolates, so each spawned isolate must register the
types it needs. Registrations are additive, and registering the same type
more than once has no additional effect.
Internal ControlError values are always treated as fatal and do not need to be registered.
This is the global exclusion policy for error capture. The complementary
ErrorMappers.only adapter selects one error type for an individual mapper.
Registration wins when an error matches both policies: the error bypasses
ErrorMappers.only and remains in Dart's error channel with its original
stack trace.
Example
class CancellationException implements Exception {}
Either.registerFatalError<CancellationException>();
Implementation
static void registerFatalError<T extends Object>() =>
_fatalErrorTests.putIfAbsent(T, () => (error) => error is T);