unierror.uts 806 B

1234567891011121314151617181920212223242526272829303132333435
  1. import { GetBatteryInfoErrorCode, GetBatteryInfoFail } from "./interface.uts"
  2. /**
  3. * 错误主题
  4. */
  5. export const UniErrorSubject = 'uni-getBatteryInfo';
  6. /**
  7. * 错误信息
  8. * @UniError
  9. */
  10. export const UniErrors: Map<GetBatteryInfoErrorCode, string> = new Map([
  11. /**
  12. * 错误码及对应的错误信息
  13. */
  14. [1001, 'getBatteryInfo:fail getAppContext is null'],
  15. [1002, 'getBatteryInfo:fail not support'],
  16. ]);
  17. /**
  18. * 错误对象实现
  19. */
  20. export class GetBatteryInfoFailImpl extends UniError implements GetBatteryInfoFail {
  21. override errCode: GetBatteryInfoErrorCode;
  22. /**
  23. * 错误对象构造函数
  24. */
  25. constructor(errCode: GetBatteryInfoErrorCode) {
  26. super();
  27. this.errSubject = UniErrorSubject;
  28. this.errCode = errCode;
  29. this.errMsg = UniErrors[errCode] ?? "";
  30. }
  31. }