DefaultErrorLocalizer class

默认本地化器(默认中文)

为所有 SmartError 子类提供默认错误消息(默认中文,可通过构造参数覆盖)。 当未配置自定义本地化器时,使用此实现。

消息列表:

  • TimeoutError: "连接超时" / "发送超时" / "接收超时" / "数据转换超时"
  • ResponseError: "服务器错误 ({statusCode})"
Implemented types

Constructors

DefaultErrorLocalizer({String networkMessage = '网络连接失败', String connectTimeoutMessage = '连接超时', String sendTimeoutMessage = '发送超时', String receiveTimeoutMessage = '接收超时', String transformTimeoutMessage = '数据转换超时', String responseMessagePrefix = '服务器错误', String parseMessage = '数据解析失败', String? businessMessage, String cancelMessage = '请求已取消', String certificateMessage = '证书验证失败', String unknownMessage = '未知错误'})
创建默认中文本地化器
const

Properties

businessMessage String?
业务错误固定消息(为空时使用服务端返回的 serverMessage)
final
cancelMessage String
取消错误消息
final
certificateMessage String
证书错误消息
final
connectTimeoutMessage String
连接超时消息
final
hashCode int
The hash code for this object.
no setterinherited
networkMessage String
网络错误消息
final
parseMessage String
解析错误消息
final
receiveTimeoutMessage String
接收超时消息
final
responseMessagePrefix String
响应错误消息前缀(最终格式:{prefix} ({statusCode})
final
runtimeType Type
A representation of the runtime type of the object.
no setterinherited
sendTimeoutMessage String
发送超时消息
final
transformTimeoutMessage String
数据转换超时消息
final
unknownMessage String
未知错误消息
final

Methods

localize(SmartError error) String
SmartError 转换为用户友好的本地化消息
override
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