Failure constructor
const
Failure({
- required String errorMessage,
- String? i18nKey,
- @Default.new(FailureCategory.unknown) FailureCategory category,
- String? code,
- String? operation,
- List<
Map< ? locations,String, dynamic> > - List? path,
- Map<
String, dynamic> ? extensions, - int? status,
- String? requestId,
- String? traceId,
- String? service,
- Map<
String, List< ? validation,String> > - @Default.new(false) bool retryable,
- DateTime? retryAfter,
- String? url,
- String? method,
- Map<
String, String> ? headers, - bool? tokenExpired,
- bool? canRefresh,
- String? debugMessage,
- String? stackTrace,
Implementation
const factory Failure({
// --- Human / UI ---
required String errorMessage, // e.g. GraphQL "message" or synthesized
String? i18nKey, // optional localization key
@Default(FailureCategory.unknown) FailureCategory category,
// --- Programmatic code & operation context ---
String? code, // e.g. extensions.code (Apollo), "UNAUTHENTICATED"
String? operation, // GraphQL operation name, if known
// --- GraphQL-specific (RFC-like shape) ---
List<Map<String, dynamic>>? locations, // [{ line, column }]
List<dynamic>? path, // ["mutation","createOrder",0,"id"]
Map<String, dynamic>? extensions, // raw passthrough
// Common extension picks (flattened for convenience)
int? status, // extensions.http.status or gateway code
String? requestId, // extensions.requestId / response header
String? traceId, // extensions.traceId / tracing
String? service, // downstream service identifier (if present)
// Validation: field -> list of messages/codes
Map<String, List<String>>? validation,
// Retry hints / rate limit
@Default(false) bool retryable,
DateTime? retryAfter, // 429-style or custom backoff
// Network/HTTP context (if available)
String? url,
String? method, // GET/POST...
Map<String, String>? headers, // response/request headers minimal subset
// Auth hints (optional, commonly present in extensions)
bool? tokenExpired,
bool? canRefresh,
// Diagnostics (hide from end-user in prod UI)
String? debugMessage,
String? stackTrace,
}) = _Failure;