Skip to content

Commit

Permalink
fix: restore code property (#320)
Browse files Browse the repository at this point in the history
Give errors both `.name` and `.code` properties for better
compatibility.
  • Loading branch information
achingbrain authored Sep 13, 2024
1 parent 1157b86 commit 414d4d0
Showing 1 changed file with 40 additions and 8 deletions.
48 changes: 40 additions & 8 deletions packages/interface-store/src/errors.ts
Original file line number Diff line number Diff line change
@@ -1,55 +1,87 @@
export class OpenFailedError extends Error {
static name = 'OpenFailedError'
static code = 'ERR_OPEN_FAILED'
name = OpenFailedError.name
code = OpenFailedError.code

constructor (message = 'Open failed') {
super(message)
this.name = 'OpenFailedError'
}
}

export class CloseFailedError extends Error {
static name = 'CloseFailedError'
static code = 'ERR_CLOSE_FAILED'
name = CloseFailedError.name
code = CloseFailedError.code

constructor (message = 'Close failed') {
super(message)
this.name = 'CloseFailedError'
}
}

export class PutFailedError extends Error {
static name = 'PutFailedError'
static code = 'ERR_PUT_FAILED'
name = PutFailedError.name
code = PutFailedError.code

constructor (message = 'Put failed') {
super(message)
this.name = 'PutFailedError'
}
}

export class GetFailedError extends Error {
static name = 'GetFailedError'
static code = 'ERR_GET_FAILED'
name = GetFailedError.name
code = GetFailedError.code

constructor (message = 'Get failed') {
super(message)
this.name = 'GetFailedError'
}
}

export class DeleteFailedError extends Error {
static name = 'DeleteFailedError'
static code = 'ERR_DELETE_FAILED'
name = DeleteFailedError.name
code = DeleteFailedError.code

constructor (message = 'Delete failed') {
super(message)
this.name = 'DeleteFailedError'
}
}

export class HasFailedError extends Error {
static name = 'HasFailedError'
static code = 'ERR_HAS_FAILED'
name = HasFailedError.name
code = HasFailedError.code

constructor (message = 'Has failed') {
super(message)
this.name = 'HasFailedError'
}
}

export class NotFoundError extends Error {
static name = 'NotFoundError'
static code = 'ERR_NOT_FOUND'
name = NotFoundError.name
code = NotFoundError.code

constructor (message = 'Not Found') {
super(message)
this.name = 'NotFoundError'
}
}

export class AbortError extends Error {
static name = 'AbortError'
static code = 'ERR_ABORTED'
name = AbortError.name
code = AbortError.code

constructor (message = 'Aborted') {
super(message)
this.name = 'AbortError'
}
}

0 comments on commit 414d4d0

Please sign in to comment.