Skip to content

Commit b33f5f4

Browse files
committed
fix: isHonoResponseError
1 parent 996314b commit b33f5f4

1 file changed

Lines changed: 4 additions & 2 deletions

File tree

src/error.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,13 @@
1+
const ERROR_NAME = 'HonoResponseError'
2+
13
export class HonoResponseError<TData, TStatus, TFormat> extends Error {
24
readonly status: TStatus
35
readonly data: TData
46
readonly format: TFormat
57

68
constructor(response: { status: TStatus; data: TData; format: TFormat }) {
79
super(JSON.stringify(response))
8-
this.name = 'HonoResponseError'
10+
this.name = ERROR_NAME
911
this.status = response.status
1012
this.data = response.data
1113
this.format = response.format
@@ -15,5 +17,5 @@ export class HonoResponseError<TData, TStatus, TFormat> extends Error {
1517
export function isHonoResponseError<T>(
1618
error: T
1719
): error is Extract<T, HonoResponseError<any, any, any>> {
18-
return error instanceof Error ? error.name === HonoResponseError.name : false
20+
return error instanceof Error ? error.name === ERROR_NAME : false
1921
}

0 commit comments

Comments
 (0)