We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 57268ca commit 14f8924Copy full SHA for 14f8924
1 file changed
docs/api/exception.md
@@ -66,16 +66,14 @@ import { HTTPException } from 'hono/http-exception'
66
67
// ...
68
69
-app.onError((error, c) => {
70
- if (error instanceof HTTPException) {
71
- console.error(error.cause)
72
- // Get the custom response
73
- return error.getResponse()
+app.onError((err, c) => {
+ if (err instanceof HTTPException) {
+ // Return the error response generated by HTTPException
+ return err.getResponse()
74
}
75
- // ...
76
- // ---cut-start---
77
- return c.text('Unexpected error')
78
- // ---cut-end---
+ // For any other unexpected errors, log and return a generic 500 response
+ console.error(err)
+ return c.text('Internal Server Error', 500)
79
})
80
```
81
0 commit comments