errors.ts 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586
  1. import { Schema } from "effect"
  2. export class InvalidRequestError extends Schema.TaggedErrorClass<InvalidRequestError>()(
  3. "InvalidRequestError",
  4. {
  5. message: Schema.String,
  6. kind: Schema.optional(Schema.String),
  7. field: Schema.optional(Schema.String),
  8. },
  9. { httpApiStatus: 400 },
  10. ) {}
  11. export class UnauthorizedError extends Schema.TaggedErrorClass<UnauthorizedError>()(
  12. "UnauthorizedError",
  13. { message: Schema.String },
  14. { httpApiStatus: 401 },
  15. ) {}
  16. export class ConflictError extends Schema.TaggedErrorClass<ConflictError>()(
  17. "ConflictError",
  18. {
  19. message: Schema.String,
  20. resource: Schema.optional(Schema.String),
  21. },
  22. { httpApiStatus: 409 },
  23. ) {}
  24. export class ServiceUnavailableError extends Schema.TaggedErrorClass<ServiceUnavailableError>()(
  25. "ServiceUnavailableError",
  26. {
  27. message: Schema.String,
  28. service: Schema.optional(Schema.String),
  29. },
  30. { httpApiStatus: 503 },
  31. ) {}
  32. export class UnknownError extends Schema.TaggedErrorClass<UnknownError>()(
  33. "UnknownError",
  34. {
  35. message: Schema.String,
  36. ref: Schema.optional(Schema.String),
  37. },
  38. { httpApiStatus: 500 },
  39. ) {}
  40. export class ProviderNotFoundError extends Schema.TaggedErrorClass<ProviderNotFoundError>()(
  41. "ProviderNotFoundError",
  42. {
  43. providerID: Schema.String,
  44. message: Schema.String,
  45. },
  46. { httpApiStatus: 404 },
  47. ) {}
  48. export class SessionNotFoundError extends Schema.TaggedErrorClass<SessionNotFoundError>()(
  49. "SessionNotFoundError",
  50. {
  51. sessionID: Schema.String,
  52. message: Schema.String,
  53. },
  54. { httpApiStatus: 404 },
  55. ) {}
  56. export class InvalidCursorError extends Schema.TaggedErrorClass<InvalidCursorError>()(
  57. "InvalidCursorError",
  58. { message: Schema.String },
  59. { httpApiStatus: 400 },
  60. ) {}
  61. export class PermissionNotFoundError extends Schema.TaggedErrorClass<PermissionNotFoundError>()(
  62. "PermissionNotFoundError",
  63. {
  64. requestID: Schema.String,
  65. message: Schema.String,
  66. },
  67. { httpApiStatus: 404 },
  68. ) {}
  69. export class QuestionNotFoundError extends Schema.TaggedErrorClass<QuestionNotFoundError>()(
  70. "QuestionNotFoundError",
  71. {
  72. requestID: Schema.String,
  73. message: Schema.String,
  74. },
  75. { httpApiStatus: 404 },
  76. ) {}