unierror.uts 700 字节
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
/**
 * 错误主题
 */
DCloud-yyl's avatar
DCloud-yyl 已提交
6
export const ExitUniErrorSubject = 'uni-exit';
DCloud-yyl's avatar
DCloud-yyl 已提交
7 8 9 10 11 12


/**
 * 错误码
 * @UniError
 */
DCloud-yyl's avatar
DCloud-yyl 已提交
13
export const ExitUniErrors:Map<number, string> = new Map([
DCloud-yyl's avatar
DCloud-yyl 已提交
14 15 16 17 18 19 20 21 22
  /**
   * 系统不支持
   */
  [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
// #ifdef APP-ANDROID
DCloud-yyl's avatar
DCloud-yyl 已提交
29
  override errCode: ExitErrorCode
DCloud-yyl's avatar
DCloud-yyl 已提交
30
// #endif
DCloud-yyl's avatar
DCloud-yyl 已提交
31 32 33 34
  constructor (
    errCode: ExitErrorCode
  ) {
    super()
DCloud-yyl's avatar
DCloud-yyl 已提交
35
    this.errSubject = ExitUniErrorSubject
DCloud-yyl's avatar
DCloud-yyl 已提交
36
    this.errCode = errCode
DCloud-yyl's avatar
DCloud-yyl 已提交
37
    this.errMsg = ExitUniErrors[errCode] ?? ''
DCloud-yyl's avatar
DCloud-yyl 已提交
38 39
  }
}