unierror.uts 653 字节
Newer Older
DCloud-yyl's avatar
DCloud-yyl 已提交
1 2
import { ExitErrorCode, IExitError } from "./interface.uts"

DCloud-yyl's avatar
DCloud-yyl 已提交
3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22
/**
 * 错误主题
 */
export const UniErrorSubject = 'uni-exit';


/**
 * 错误码
 * @UniError
 */
export const UniErrors:Map<number, string> = new Map([
  /**
   * 系统不支持
   */
  [12001, 'system not support'],
  /**
   * 未知错误
   */
  [12002, 'unknown error']
]);
DCloud-yyl's avatar
DCloud-yyl 已提交
23 24 25 26 27

/**
 * ExitFail的实现
 */
export class ExitFailImpl extends UniError implements IExitError {
DCloud-yyl's avatar
DCloud-yyl 已提交
28
  override errCode: ExitErrorCode
DCloud-yyl's avatar
DCloud-yyl 已提交
29 30 31 32 33 34 35 36 37
  constructor (
    errCode: ExitErrorCode
  ) {
    super()
    this.errSubject = UniErrorSubject
    this.errCode = errCode
    this.errMsg = UniErrors[errCode] ?? "";
  }
}