Add Standard Error Handling for undefined Routes
pfiadDi opened this issue · 1 comments
pfiadDi commented
Hi, great work with this library!
When the user access a route not defined it throws an error from bun server.ts:
Cannot GET /something
λ() node_modules/bunrest/src/server/server.ts:210:16
// append req route params
req.params = leaf.routeParams;
// fix (issue 4: unhandle route did not throw an error)
if (!handlers || handlers.length === 0) {
throw new Error(`Cannot ${req.method} ${req.path}`);
/* ^ happened here */
Stack trace:
λ() node_modules/bunrest/src/server/server.ts:210:16
Info:
bun v1.0.3
linux #33~22.04.1-Ubuntu SMP PREEMPT_DYNAMIC Thu Sep 7 10:33:52 UTC 2 (x64)
User-Agent: Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/117.0.0.0 Safari/537.36
Pathname: /something
While in epxressjs it gives a "nice" standard
Cannot GET /something with a 404
Most importantly, no error in the console and therefore logs.
Would be great if that could be a implemented.
lau1944 commented
Added