ref(angular): using InjectionToken and optional configuration
Using InjectionToken and optional configuration.
This way I can inject the SentryErrorHandler into my custom ErrorHandler.
Before submitting a pull request, please take a look at our Contributing guidelines and verify:
- [ ] If you've added code that should be tested, please add tests.
- [x] Ensure your code lints and the test suite passes (
yarn lint) & (yarn test).
In fact, using the spread operator in a literal object will not throw a TypeError .
{ ...null };
{ ...undefined };
var a = null;
var b = undefined;
var c = { n: 'cccc', ...a, ...b };
To be on the safe side, I changed it to
{
logErrors: true,
...(options || {}),
}
Hey @iaosee, thanks for opening up this PR and sorry for the long delay to getting back to you.
Could you explain your use-case a bit more in detail?
We typically recommend extending our error handler: https://docs.sentry.io/platforms/javascript/guides/angular/features/error-handler/#multiple-error-handlers
Does that not work for you?
Hey @andreiborza, thanks for your reply.
It works perfectly, that's what I'm doing now. However, replacing "errorHandlerOptions" with "InjectionToken" here is a better practice. Now there are no problems; you can merge or close this PR.
Thanks, I'll close this for now because it's a breaking change. We can think of revisiting/changing this if more people run into.