Skip to content

Commit 6a582e4

Browse files
authored
fix: server$ not throwing for errors above 500 (#7078)
1 parent a1b44df commit 6a582e4

File tree

2 files changed

+8
-3
lines changed

2 files changed

+8
-3
lines changed

.changeset/three-donkeys-admire.md

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'@builder.io/qwik-city': patch
3+
---
4+
5+
server$ functions now correctly throw errors for > 500 error codes

packages/qwik-city/src/runtime/src/server-functions.ts

+3-3
Original file line numberDiff line numberDiff line change
@@ -479,19 +479,19 @@ export const serverQrl = <T extends ServerFunction>(
479479
} else if (contentType === 'application/qwik-json') {
480480
const str = await res.text();
481481
const obj = await _deserializeData(str, ctxElm ?? document.documentElement);
482-
if (res.status === 500) {
482+
if (res.status >= 500) {
483483
throw obj;
484484
}
485485
return obj;
486486
} else if (contentType === 'application/json') {
487487
const obj = await res.json();
488-
if (res.status === 500) {
488+
if (res.status >= 500) {
489489
throw obj;
490490
}
491491
return obj;
492492
} else if (contentType === 'text/plain' || contentType === 'text/html') {
493493
const str = await res.text();
494-
if (res.status === 500) {
494+
if (res.status >= 500) {
495495
throw str;
496496
}
497497
return str;

0 commit comments

Comments
 (0)