unierror.uts 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. import { ICreateSQLiteContextError } from "./interface.uts"
  2. /**
  3. * 错误主题
  4. */
  5. export const UniErrorSubject = 'uni-create-sql-context';
  6. /**
  7. * 错误码
  8. * @UniError
  9. */
  10. export const UniErrors: Map<number, string> = new Map([
  11. /**
  12. * 数据库启动失败
  13. */
  14. [1000001, 'Database startup failed'],
  15. /**
  16. * 执行SQL增删改语句失败
  17. */
  18. [1000002, 'Failed to execute SQL insert, update, delete statement'],
  19. /**
  20. * 执行SQL查询语句失败
  21. */
  22. [1000003, 'Failed to execute SQL query statement'],
  23. /**
  24. * 事务开始失败
  25. */
  26. [1000004, 'Transaction start failed'],
  27. /**
  28. * 事务提交失败
  29. */
  30. [1000005, 'Transaction commit failed'],
  31. /**
  32. * 事务回滚失败
  33. */
  34. [1000006, 'Transaction rollback failed'],
  35. /**
  36. * 数据库关闭失败
  37. */
  38. [1000007, 'Database shutdown failed'],
  39. /**
  40. * 未知错误
  41. */
  42. [1000008, 'Unknown error'],
  43. ]);
  44. export class createSQLiteContextFailImpl extends UniError implements ICreateSQLiteContextError {
  45. override errCode: number
  46. constructor(
  47. errCode: number
  48. ) {
  49. super()
  50. this.errSubject = UniErrorSubject
  51. this.errCode = errCode
  52. this.errMsg = UniErrors[errCode] ?? ''
  53. }
  54. }