failure method
Signals that the service could not complete its work.
outcomes accepts a single String or a List<String>. The optional
context carries whatever the caller needs to act on the failure:
// carry the invalid entity so the caller can render field errors
return failure('validationFailed', invalidUser);
// multiple outcomes with context
return failure(['unprocessableContent', 'clientError'], response);
// outcome tag alone is enough
return failure('unauthorized');
See also success for the happy path, check for inline validation, tryRun for wrapping operations that may throw.
Implementation
Failure<Value> failure(Object? outcomes, [Object? context]) => Failure(outcomes, context);