nest-raven
nest-raven copied to clipboard
Capture Additional data (req) when console.error occurs
Package + Version
- [ ]
@sentry/node
- [ ] other:
nest-raven
Version:
latest
Description
When my code throw error, I can get the ADDITIONAL DATA
with req
field as you can see it here:
But when my code does not throw anything and it use console.error
instead, it only show something like this:
My Sentry setup:
Could you please give me an approach get the ADDITIONAL DATA
with req
field like the first image?
Hmm, that looks like it's related to #22. Which means that nest-raven doesn't expose ADDITIONAL DATA
to exceptions not captured by nest-raven itself. When you use console.error
this isn't handled by nest-raven
so no additional data is provided.
@mentos1386 Do you have a plan to fix this issue, I can use sample a hack like this:
// Inside a controller
try {
something();
} catch (e) {
console.error(e.message, req); // here req is the request that is sent
}
But it seem it is not a good idea, what do you think?
The plan is for this to be fixed with #22.
Otherwise. It's a good practice to throw/faill when error happens. And not just logging it to stdout/stderr. Then you can handle that exception with exception filter https://docs.nestjs.com/exception-filters.
@mentos1386 Thank you for your plan. Throw error is a good practice but for me I am maintaining a project that has many messy code with no document, sometimes I just want to capture events when something occur with console.warn
and console.error
instead of throw error, imagine you have an app solving vehicle routing problem with time windows, it is has many situations and results.
@bugb Hi
new integrations.CaptureConsole({....})
is you definiton or where you found it? I cant find in in source code. Thanks
@bendadaniel that is provided by @sentry/integrations
package. You can read more here https://getsentry.github.io/sentry-javascript/classes/_sentry_integrations.CaptureConsole.html.
Closing this as original issue would be addressed by #22.