Failure class sealed

Available extensions
Annotations
  • @Freezed.new(toJson: true, fromJson: true)

Constructors

Failure({required String errorMessage, String? i18nKey, @Default.new(FailureCategory.unknown) FailureCategory category, String? code, String? operation, List<Map<String, dynamic>>? locations, List? path, Map<String, dynamic>? extensions, int? status, String? requestId, String? traceId, String? service, Map<String, List<String>>? validation, @Default.new(false) bool retryable, DateTime? retryAfter, String? url, String? method, Map<String, String>? headers, bool? tokenExpired, bool? canRefresh, String? debugMessage, String? stackTrace})
const
factory
Failure.fromGraphQLError(Map<String, dynamic> err, {String? operation, String? url, String? method})
Build from a GraphQL error map (Apollo/Ktor/etc). Accepts the standard shape: { message, locations, path, extensions: { code, http: { status }, requestId, traceId, validationErrors, retryAfter, ... } }
factory
Failure.fromHttp({String? message, int? status, String? url, String? method, Map<String, String>? headers, String? requestId, String? traceId, String? code, Map<String, dynamic>? body, bool? retryable})
Build from an HTTP failure (non-2xx) or thrown client exception.
factory
Failure.fromJson(Map<String, dynamic> json)
factory
Failure.network([String? message])
Build for network errors (no response).
factory
Failure.timeout([String? message])
Build for timeouts.
factory

Properties

canRefresh bool?
no setterinherited
category FailureCategory
no setterinherited
code String?
no setterinherited
copyWith → $FailureCopyWith<Failure>
Create a copy of Failure with the given fields replaced by the non-null parameter values.
no setterinherited
debugMessage String?
no setterinherited
errorMessage String
no setterinherited
extensions Map<String, dynamic>?
no setterinherited
hashCode int
The hash code for this object.
no setterinherited
headers Map<String, String>?
no setterinherited
i18nKey String?
no setterinherited
isAuthError bool
no setter
isRateLimited bool
no setter
locations List<Map<String, dynamic>>?
no setterinherited
method String?
no setterinherited
operation String?
no setterinherited
path List?
no setterinherited
requestId String?
no setterinherited
retryable bool
no setterinherited
retryAfter DateTime?
no setterinherited
runtimeType Type
A representation of the runtime type of the object.
no setterinherited
service String?
no setterinherited
stackTrace String?
no setterinherited
status int?
no setterinherited
tokenExpired bool?
no setterinherited
traceId String?
no setterinherited
uiMessage String
Friendly message for UI.
no setter
url String?
no setterinherited
validation Map<String, List<String>>?
no setterinherited

Methods

map<TResult extends Object?>(TResult $default(_Failure value)) → TResult

Available on Failure, provided by the FailurePatterns extension

A switch-like method, using callbacks.
mapOrNull<TResult extends Object?>(TResult? $default(_Failure value)?) → TResult?

Available on Failure, provided by the FailurePatterns extension

A variant of map that fallback to returning null.
maybeMap<TResult extends Object?>(TResult $default(_Failure value)?, {required TResult orElse()}) → TResult

Available on Failure, provided by the FailurePatterns extension

A variant of map that fallback to returning orElse.
maybeWhen<TResult extends Object?>(TResult $default(String errorMessage, String? i18nKey, FailureCategory category, String? code, String? operation, List<Map<String, dynamic>>? locations, List? path, Map<String, dynamic>? extensions, int? status, String? requestId, String? traceId, String? service, Map<String, List<String>>? validation, bool retryable, DateTime? retryAfter, String? url, String? method, Map<String, String>? headers, bool? tokenExpired, bool? canRefresh, String? debugMessage, String? stackTrace)?, {required TResult orElse()}) → TResult

Available on Failure, provided by the FailurePatterns extension

A variant of when that fallback to an orElse callback.
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
toJson() Map<String, dynamic>
Serializes this Failure to a JSON map.
inherited
toString() String
A string representation of this object.
inherited
when<TResult extends Object?>(TResult $default(String errorMessage, String? i18nKey, FailureCategory category, String? code, String? operation, List<Map<String, dynamic>>? locations, List? path, Map<String, dynamic>? extensions, int? status, String? requestId, String? traceId, String? service, Map<String, List<String>>? validation, bool retryable, DateTime? retryAfter, String? url, String? method, Map<String, String>? headers, bool? tokenExpired, bool? canRefresh, String? debugMessage, String? stackTrace)) → TResult

Available on Failure, provided by the FailurePatterns extension

A switch-like method, using callbacks.
whenOrNull<TResult extends Object?>(TResult? $default(String errorMessage, String? i18nKey, FailureCategory category, String? code, String? operation, List<Map<String, dynamic>>? locations, List? path, Map<String, dynamic>? extensions, int? status, String? requestId, String? traceId, String? service, Map<String, List<String>>? validation, bool retryable, DateTime? retryAfter, String? url, String? method, Map<String, String>? headers, bool? tokenExpired, bool? canRefresh, String? debugMessage, String? stackTrace)?) → TResult?

Available on Failure, provided by the FailurePatterns extension

A variant of when that fallback to returning null

Operators

operator ==(Object other) bool
The equality operator.
inherited