T
TanStack4mo ago
conscious-sapphire

How to trycatch the entire defaultAPIFileRouteHandler and return a 500 status code ?

I want to return a 500 status code when any of the /api/ routes throw an error. Currently by default setup from the docs shows this with the stack trace. how do i manage to try catch all the /api/ routes and return a 500 with like the following json { message: "internal server errror" } i also would like to have the exception console.log()-ed how do i manage to do this ?
No description
5 Replies
foreign-sapphire
foreign-sapphire4mo ago
should be possible with Middlewares on the alpha branch
sharp-indigo
sharp-indigo4mo ago
Have middlewares changed in the alpha version that you mentioned?
foreign-sapphire
foreign-sapphire4mo ago
there were no middlewares aside from server functions now you can attach middlewares to "server routes" which replace API routes . much more generic concept now
conscious-sapphire
conscious-sapphireOP4mo ago
i see. I guess i should just wait for a stable release before jumping in. not to put anyone on edge but, is there any branch or issue or github project where i can see the progress on the release ?
foreign-sapphire
foreign-sapphire4mo ago
you can use the alpha version already now just install with @alpha

Did you find this page helpful?