Skip to content

Commit

Permalink
enhance errors
Browse files Browse the repository at this point in the history
  • Loading branch information
patroza committed Nov 17, 2023
1 parent c9c3085 commit de41961
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 3 deletions.
6 changes: 6 additions & 0 deletions .changeset/quiet-cougars-sing.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
"@effect-app/prelude": patch
"@effect-app/infra": patch
---

enhance errors
13 changes: 11 additions & 2 deletions packages/infra/_src/errors.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,18 @@ export class NotFoundError<T extends string = string>

export class ValidationError extends Data.TaggedError("ValidationError")<{ errors: ReadonlyArray<unknown> }> {}

export class NotLoggedInError extends Data.TaggedError("NotLoggedInError")<{ message?: string }> {}
export class NotLoggedInError extends Data.TaggedError("NotLoggedInError")<{ message?: string }> {
constructor(message?: string) {
super({ message })
}
}

export class UnauthorizedError extends Data.TaggedError("UnauthorizedError")<{ message?: string }> {
constructor(message?: string) {
super({ message })
}
}

export class UnauthorizedError extends Data.TaggedError("UnauthorizedError")<{}> {}
/**
* The user carries a valid Userprofile, but there is a problem with the login none the less.
*/
Expand Down
3 changes: 2 additions & 1 deletion packages/prelude/_src/client/errors.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,8 @@ export class NotLoggedInError extends Model<NotLoggedInError>()({

@useClassFeaturesForSchema
export class UnauthorizedError extends Model<UnauthorizedError>()({
_tag: prop(literal("UnauthorizedError"))
_tag: prop(literal("UnauthorizedError")),
message: prop(string).optional
}) {}

@useClassFeaturesForSchema
Expand Down

0 comments on commit de41961

Please sign in to comment.