unierror.uts 841 字节
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
	
DCloud-yyl's avatar
DCloud-yyl 已提交
15 16 17 18 19 20 21
  /**
   * 系统不支持
   */
  [12001, 'system not support'],
  /**
   * 未知错误
   */
DCloud-yyl's avatar
DCloud-yyl 已提交
22 23 24 25 26
  [12002, 'unknown error'],
  /**
   * iOS平台,仅在uni-app x SDK模式中支持应用退出
   */
  [12003, 'app exit is supported only in uni-app x SDK mode']
DCloud-yyl's avatar
DCloud-yyl 已提交
27
]);
DCloud-yyl's avatar
DCloud-yyl 已提交
28 29 30 31 32

/**
 * ExitFail的实现
 */
export class ExitFailImpl extends UniError implements IExitError {
DCloud-yyl's avatar
DCloud-yyl 已提交
33
// #ifdef APP-ANDROID
DCloud-yyl's avatar
DCloud-yyl 已提交
34
  override errCode: ExitErrorCode
DCloud-yyl's avatar
DCloud-yyl 已提交
35
// #endif
DCloud-yyl's avatar
DCloud-yyl 已提交
36 37 38 39
  constructor (
    errCode: ExitErrorCode
  ) {
    super()
DCloud-yyl's avatar
DCloud-yyl 已提交
40
    this.errSubject = ExitUniErrorSubject
DCloud-yyl's avatar
DCloud-yyl 已提交
41
    this.errCode = errCode
DCloud-yyl's avatar
DCloud-yyl 已提交
42
    this.errMsg = ExitUniErrors[errCode] ?? ''
DCloud-yyl's avatar
DCloud-yyl 已提交
43 44
  }
}