diff --git a/.changeset/cuddly-peas-deny.md b/.changeset/cuddly-peas-deny.md new file mode 100644 index 0000000..46d3b98 --- /dev/null +++ b/.changeset/cuddly-peas-deny.md @@ -0,0 +1,5 @@ +--- +"@softnetics/hono-react-query": patch +--- + +Fix isHonoResponseError does not work properly in production diff --git a/src/error.ts b/src/error.ts index b71873d..4c70adb 100644 --- a/src/error.ts +++ b/src/error.ts @@ -1,3 +1,5 @@ +const ERROR_NAME = 'HonoResponseError' + export class HonoResponseError extends Error { readonly status: TStatus readonly data: TData @@ -5,7 +7,7 @@ export class HonoResponseError extends Error { 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 @@ -15,5 +17,5 @@ export class HonoResponseError extends Error { export function isHonoResponseError( error: T ): error is Extract> { - return error instanceof Error ? error.name === HonoResponseError.name : false + return error instanceof Error ? error.name === ERROR_NAME : false }