where cookies??? where res?
Hi everyone, I'm not using cookies at all, or trying to mess with the headers myself and am getting this error in a POST handler:
[NOTE]: i'm porting this from express to hono and the logic hasn't changed and this has been working forever (in express)
[ALSO]: the user is created in the database, the email is sent and received...
this is my code:
15 Replies
Are you using app.onError, if not turn that on and console log the error. It might give you a better error message
hey @Nico , thanks for the assist.
I finally figured out what was happening and was now coming back here to report on it.
app.onError catches everything that isn't solved by a try catch? that is extremely useful, thanks
the answer to this problem has to do with the simple fact that i wasn't returning my
await db.transaction(async (tx) => {
so,
the cryptic error, with _res.headers
happens everytime in hono when a handler doesn't return a responseI'm not sure why it's showing that, I do usually see it say a response was not retuned
it may be the fact i'm using Bun.serve
i have noticed the error logging in bun needs a lot of work
but yeah, not sure
And yes if you use
app.onError
it will catch all unhandled errors
So in my preference I don't use any try/catch inside a route or middleware. I have a error handler to see all the erorrs and throw the proper response
It might be a ts thing tooi will definitely work on implementing that this weekend, before it becomes too difficult
what happens to the response, on app.onError?
can we still return a 501?
I'll give you an example:
Look at this error handler
https://github.com/phxlab/gametime-server/blob/main/src/lib/errors/mongoose.ts
And it's handled in this app.onError
https://github.com/phxlab/gametime-server/blob/main/src/app.ts
I can still throw a default error if nothing matches
yeah, that's perfect :;
GitHub
GitHub - NicoPlyley/hono-error-handler
Contribute to NicoPlyley/hono-error-handler development by creating an account on GitHub.
getting happier and happier with hono
Here's the error handler I made if you want to use it. I need to update the documentation a bit I made it in a rush
will definitely look into it
are you part of the hono team? or just a helping angel?
Just a helper and contributor. I help most by answering questions and managing the Discord
well thank you
No problem! It's what I enjoy doing