Err<T extends Object> constructor
Err<T extends Object> (})
Creates a new Err from value and an optional statusCode.
Implementation
Err(
super.value, {
int? statusCode,
StackTrace? stackTrace,
List<String> breadcrumbs = const [],
}) : statusCode = Option.from(statusCode),
// Defensive trace capture. `Trace.from`/`Trace.current` can throw
// `FormatException` on malformed native stack-trace strings (most
// visibly on dart2wasm). The whole point of `df_safer_dart` is that
// error handling never itself throws — so the trace is computed via
// a safe helper that falls back to an empty `Trace` rather than
// letting the throw escape every `Err(...)` call site.
stackTrace = _safeStackTrace(stackTrace),
// Skip the `List.unmodifiable` allocation when no breadcrumbs were
// supplied — the default `const []` is already unmodifiable and is
// the dominant code path.
breadcrumbs = breadcrumbs.isEmpty
? const <String>[]
: List.unmodifiable(breadcrumbs),
super._();