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
// NEXT
app.get('/test', () => {
if (somethingBad) return new Response("that doesn't exist", { status: 404 });
return 'yay';
});
Alternatively (or in addition to) throwing an error and attaching status should have the same affect. This can already be achieved manually today via custom onError handler to detect status in error. Ideally this would be out of the box behavior. Exposing ErrorStatus class would also make this type safe (ala throw new ErrorStatus('something wrong', 400)).
Awesome package otherwise!
The text was updated successfully, but these errors were encountered:
sometimes it would be handy to be able to throw a response and have Elysia respond with it. For example, let's say in derive() we come across an error and want to respond instead of returning the derived context. Currently, throwing a response seems to respond with the correct status, but the response body is always empty.
if we allow returning Response objects, we could also expose a generic Response interface, so we will be able to infer response type from Response.json(), similar to fets.
The docs aren't super clear on this subject, but I see no reason the formal Bun format could not auto translate.
Basically in addition to the current pattern, it would be very desirable to also support
new Response
:Would be great if this worked as well!
Alternatively (or in addition to) throwing an error and attaching
status
should have the same affect. This can already be achieved manually today via customonError
handler to detectstatus
inerror
. Ideally this would be out of the box behavior. ExposingErrorStatus
class would also make this type safe (alathrow new ErrorStatus('something wrong', 400)
).Awesome package otherwise!
The text was updated successfully, but these errors were encountered: