Skip to content

Commit

Permalink
fix: server$ not throwing for errors above 500 (#7078)
Browse files Browse the repository at this point in the history
  • Loading branch information
DustinJSilk authored Nov 25, 2024
1 parent a1b44df commit 6a582e4
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
5 changes: 5 additions & 0 deletions .changeset/three-donkeys-admire.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@builder.io/qwik-city': patch
---

server$ functions now correctly throw errors for > 500 error codes
6 changes: 3 additions & 3 deletions packages/qwik-city/src/runtime/src/server-functions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -479,19 +479,19 @@ export const serverQrl = <T extends ServerFunction>(
} else if (contentType === 'application/qwik-json') {
const str = await res.text();
const obj = await _deserializeData(str, ctxElm ?? document.documentElement);
if (res.status === 500) {
if (res.status >= 500) {
throw obj;
}
return obj;
} else if (contentType === 'application/json') {
const obj = await res.json();
if (res.status === 500) {
if (res.status >= 500) {
throw obj;
}
return obj;
} else if (contentType === 'text/plain' || contentType === 'text/html') {
const str = await res.text();
if (res.status === 500) {
if (res.status >= 500) {
throw str;
}
return str;
Expand Down

0 comments on commit 6a582e4

Please sign in to comment.