errors.ts 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101
  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. ) {}
  77. export class ForbiddenError extends Schema.TaggedErrorClass<ForbiddenError>()(
  78. "ForbiddenError",
  79. { message: Schema.String },
  80. { httpApiStatus: 403 },
  81. ) {}
  82. export class PtyNotFoundError extends Schema.TaggedErrorClass<PtyNotFoundError>()(
  83. "PtyNotFoundError",
  84. {
  85. ptyID: Schema.String,
  86. message: Schema.String,
  87. },
  88. { httpApiStatus: 404 },
  89. ) {}