合同小程序前端代码仓库
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

40 lines
909 B

3 months ago
  1. // @ts-nocheck
  2. /* 此规范为 uni 规范,可以按照自己的需要选择是否实现 */
  3. import { MyApiErrorCode, MyApiFail } from "./interface.uts"
  4. /**
  5. * 错误主题
  6. * 注意:错误主题一般为插件名称,每个组件不同,需要使用时请更改。
  7. * [可选实现]
  8. */
  9. export const UniErrorSubject = 'uts-api';
  10. /**
  11. * 错误信息
  12. * @UniError
  13. * [可选实现]
  14. */
  15. export const MyAPIErrors : Map<MyApiErrorCode, string> = new Map([
  16. /**
  17. * 错误码及对应的错误信息
  18. */
  19. [9010001, 'custom error mseeage1'],
  20. [9010002, 'custom error mseeage2'],
  21. ]);
  22. /**
  23. * 错误对象实现
  24. */
  25. export class MyApiFailImpl extends UniError implements MyApiFail {
  26. /**
  27. * 错误对象构造函数
  28. */
  29. constructor(errCode : MyApiErrorCode) {
  30. super();
  31. this.errSubject = UniErrorSubject;
  32. this.errCode = errCode;
  33. this.errMsg = MyAPIErrors.get(errCode) ?? "";
  34. }
  35. }