Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/cuddly-peas-deny.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@softnetics/hono-react-query": patch
---

Fix isHonoResponseError does not work properly in production
6 changes: 4 additions & 2 deletions src/error.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
const ERROR_NAME = 'HonoResponseError'

export class HonoResponseError<TData, TStatus, TFormat> extends Error {
readonly status: TStatus
readonly data: TData
readonly format: TFormat

constructor(response: { status: TStatus; data: TData; format: TFormat }) {
super(JSON.stringify(response))
this.name = 'HonoResponseError'
this.name = ERROR_NAME
this.status = response.status
this.data = response.data
this.format = response.format
Expand All @@ -15,5 +17,5 @@ export class HonoResponseError<TData, TStatus, TFormat> extends Error {
export function isHonoResponseError<T>(
error: T
): error is Extract<T, HonoResponseError<any, any, any>> {
return error instanceof Error ? error.name === HonoResponseError.name : false
return error instanceof Error ? error.name === ERROR_NAME : false
}
Loading