You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Error management could be improved; throw error() for json endpoints (+server.ts) responds with double body, response needs to be way more generic and status code is ignored
#10672
+server.ts sends a throw error(401, "Not auth'd"), the client get a double body and http code 401 is ignored:
body{status: 401,body: {message: "Not auth'd"}}// the actual http code is not 401
Is this a problem? Yes and no. No, because we can just deal with it.
Yes, because I'd like to have one generic error object that feels well designed for everything:
+page.server.ts
+server.ts
errors displayed inline forms
errors shown via notifications
errors shown via modals
errors rendered as redirects
combinations of latter ones
Now, we can build our own generic error object and just ignore SvelteKit's error() but then we'll miss out on +error.svelte. Or we'd need to build this with redirect's ourselves too.
Changing error's shape to something more generic would we breaking, not sure if it would be worth it but maybe it's worth a try. Error management is a huge chunk of any web app,.
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
+server.ts
sends athrow error(401, "Not auth'd")
, the client get a double body and http code 401 is ignored:Is this a problem? Yes and no. No, because we can just deal with it.
Yes, because I'd like to have one generic error object that feels well designed for everything:
+page.server.ts
+server.ts
Now, we can build our own generic error object and just ignore SvelteKit's
error()
but then we'll miss out on+error.svelte
. Or we'd need to build this with redirect's ourselves too.Changing error's shape to something more generic would we breaking, not sure if it would be worth it but maybe it's worth a try. Error management is a huge chunk of any web app,.
Beta Was this translation helpful? Give feedback.
All reactions