1. 异常处理
VIP3平台内核提供了统一的错误类 Error ,并内置如下异常处理器:
1.1. 自定义错误类(Error)
平台提供的异常类在原生 Error 的基础上,增加了错误码(code)和错误详情(details)属性。
class Error {
// 错误名
name
// 错误消息
message
// 错误堆栈
stack
////// 以下为自定义属性
// 错误码
code
// 错误详情,如:上下文、自定义数据
details
constructor(message, code, details) {
this.name = this.constructor.name
this.message = message
this.code = code
this.details = details
}
}
这样前端VIP3平台的错误类就和后台UBP平台的错误类保持一致了!!!