Skip to content
This repository has been archived by the owner on Jun 26, 2023. It is now read-only.

Commit

Permalink
feat: add CodeError
Browse files Browse the repository at this point in the history
  • Loading branch information
tabcat committed Nov 22, 2022
1 parent 36e772e commit 4378360
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions packages/interfaces/src/errors.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,3 +17,18 @@ export class AbortError extends Error {
return 'aborted'
}
}

export class CodeError<T extends Record<string, any> = Record<string, never>> extends Error {
public readonly props: T

constructor (
message: string,
public readonly code: string,
props?: T
) {
super(message)

this.name = 'CodeError'
this.props = props ?? {} as T // eslint-disable-line @typescript-eslint/consistent-type-assertions
}
}

0 comments on commit 4378360

Please sign in to comment.