unierror.uts 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. import { ReportErrorCode, ReportError } from "./interface.uts"
  2. /**
  3. * 错误主题
  4. */
  5. export const ReportUniErrorSubject = 'uni-report';
  6. /**
  7. * 错误码
  8. * @UniError
  9. */
  10. export const ReportUniErrors:Map<number, string> = new Map([
  11. /**
  12. * 已集成uni统计,但未关联服务空间
  13. */
  14. [61000, '应用已集成uni统计,但未关联服务空间,请在uniCloud目录右键关联服务空间!'],
  15. /**
  16. * 统计已集成,但未初始化
  17. */
  18. [61001, '统计服务尚未初始化,请在main.uts中引入统计插件!'],
  19. /**
  20. * 调用失败
  21. */
  22. [61002, 'uni-app-launch 下 options 参数必填,请检查!'],
  23. [61003, 'Report的 name参数必填'],
  24. [61004, 'Report的name参数类型必须为字符串'],
  25. [61005, 'Report的name参数长度最大为255'],
  26. [61006, 'Report的options参数只能为String或者Object类型'],
  27. [61007, 'Report的options参数若为String类型,则长度最大为255'],
  28. [61008, 'Report的name参数为title时,options参数类型只能为String'],
  29. ]);
  30. /**
  31. * ReportFail的实现
  32. */
  33. export class ReportFailImpl extends UniError implements ReportError {
  34. override errCode: ReportErrorCode
  35. constructor (
  36. errCode: ReportErrorCode
  37. ) {
  38. super()
  39. this.errSubject = ReportUniErrorSubject
  40. this.errCode = errCode
  41. this.errMsg = ReportUniErrors.get(errCode) ?? ''
  42. }
  43. }