ErrorKey class

错误键,用于精确定位错误消息

支持基于错误类型和可选子键(如 TimeoutPhase)进行消息定位。

示例:

// 为所有 NetworkError 设置消息
ErrorKey.network

// 为特定超时阶段设置消息
ErrorKey.timeout(TimeoutPhase.connect)

// 从错误实例创建
final key = ErrorKey.fromError(error);

Properties

hashCode int
The hash code for this object.
no setteroverride
runtimeType Type
A representation of the runtime type of the object.
no setterinherited
subKey Object?
可选子键(如 TimeoutPhase)
final
type Type
错误类型
final

Methods

context(SmartError e) Map<String, Object?>
提取错误的上下文变量(用于模板插值)
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
toString() String
A string representation of this object.
override

Operators

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

Static Methods

fromError(SmartError e) ErrorKey
从错误实例创建键
timeout([TimeoutPhase? phase]) ErrorKey
TimeoutError 的键(可指定阶段)

Constants

business → const ErrorKey
BusinessError 的键
cancel → const ErrorKey
CancelError 的键
certificate → const ErrorKey
CertificateError 的键
network → const ErrorKey
NetworkError 的键
parse → const ErrorKey
ParseError 的键
response → const ErrorKey
ResponseError 的键
unknown → const ErrorKey
UnknownError 的键