Skip to content

Commit

Permalink
fix(server): use Response ctor if Response.error not implemented
Browse files Browse the repository at this point in the history
  • Loading branch information
ardatan committed Oct 23, 2023
1 parent 0c04fce commit e4061de
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
5 changes: 5 additions & 0 deletions .changeset/three-laws-care.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@whatwg-node/server': patch
---

If Response.error is not implemented, use Response ctor directly
5 changes: 4 additions & 1 deletion packages/server/src/plugins/useErrorHandling.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,10 @@ export function createDefaultErrorHandler<TServerContext = {}>(
);
}
console.error(e);
return ResponseCtor.error();
if (ResponseCtor.error) {
return ResponseCtor.error();
}
return new ResponseCtor(null, { status: 500 });
};
}

Expand Down

0 comments on commit e4061de

Please sign in to comment.