How to use tiny-http with Sentry for error monitoring? #384
-
Is this possible to use tiny-http with |
Beta Was this translation helpful? Give feedback.
Answered by
aarontravass
May 10, 2023
Replies: 1 comment 2 replies
-
Initiate Sentry in your root file. Then, create a middlware that can be passed to the import { captureException } from '@sentry/node';
import { App } from '@tinyhttp/app';
const errorHandler = (error, req, res) => {
captureException(error);
return res.send("Server error!")
}
const app = new App({ onError: errorHandler });
app.get('/user', (req, res) => {
throw Error('error!');;
})
app.listen(3000, () => { console.log("listening!") }) |
Beta Was this translation helpful? Give feedback.
2 replies
Answer selected by
talentlessguy
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Initiate Sentry in your root file.
Then, create a middlware that can be passed to the
onError
handler