Skip to content

Commit f718d07

Browse files
authored
Merge pull request #16 from softnetics/yu/fix/is-hono-response
2 parents c57bca3 + e4b6dc2 commit f718d07

2 files changed

Lines changed: 9 additions & 2 deletions

File tree

.changeset/cuddly-peas-deny.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"@softnetics/hono-react-query": patch
3+
---
4+
5+
Fix isHonoResponseError does not work properly in production

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)