SmartErrorLocalizer class abstract

错误消息本地化器接口

实现此接口以提供自定义的错误消息本地化。

示例:

class MyLocalizer implements SmartErrorLocalizer {
  @override
  String localize(SmartError error) => switch (error) {
    NetworkError() => 'Network unavailable',
    TimeoutError() => 'Request timed out',
    ResponseError(:final statusCode) => 'Server error: $statusCode',
    ParseError() => 'Failed to parse data',
    BusinessError(:final serverMessage) => serverMessage,
    CancelError() => 'Request cancelled',
    CertificateError() => 'Certificate error',
    UnknownError() => 'Unknown error',
  };
}
Implementers

Constructors

SmartErrorLocalizer()

Properties

hashCode int
The hash code for this object.
no setterinherited
runtimeType Type
A representation of the runtime type of the object.
no setterinherited

Methods

localize(SmartError error) String
SmartError 转换为用户友好的本地化消息
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
toString() String
A string representation of this object.
inherited

Operators

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