1import { Schema } from "effect"
2
3export class UserNotFound extends Schema.TaggedError<UserNotFound>()(
4 "UserNotFound",
5 {},
6 // You can specify the status code for this error inline
7 { httpApiStatus: 404 }
8) {}
9
10export class SearchQueryTooShort
11 extends Schema.TaggedError<SearchQueryTooShort>()("SearchQueryTooShort", {}, { httpApiStatus: 422 })
12{
13 static readonly minimumLength = 2
14}
15
16// Create a wrapper error class for all errors in the Users API.
17//
18// This prevents adding too many error types to services / endpoint definitions.
19//
20export class UsersError extends Schema.TaggedError<UsersError>()("UsersError", {
21 reason: Schema.Union([UserNotFound, SearchQueryTooShort])
22}) {}