Sentry-javascript: Sentry.captureException - Expected 1 arguments, but got 2.

Created on 18 Dec 2018  路  2Comments  路  Source: getsentry/sentry-javascript

Package + Version

  • [ ] @sentry/browser
  • [x] @sentry/node
  • [ ] raven-js
  • [ ] raven-node _(raven for node)_
  • [ ] other:

Version:

4.4.2

Description

Hello,

My typescript validator throw me an error for captureException method with a problem of argument. The type expect 1 argument, the error, but do not want the second argument data.

Ex:

Sentry.captureException(new Error(msg), {
  extra: {
    ...data,
  },
})

error TS2554: Expected 1 arguments, but got 2.

Thanks

ps: I can make a _PR_ if you want.

Most helpful comment

The second argument is only supported in raven-js/raven-node from what I can see. You'll have to do something like this in @sentry/*:

Sentry.withScope(scope => {
  scope.setTag('tagName', 'tagValue')
  scope.setExtra('extraName', 'extraValue')
  Sentry.captureException(err)
})

All 2 comments

The second argument is only supported in raven-js/raven-node from what I can see. You'll have to do something like this in @sentry/*:

Sentry.withScope(scope => {
  scope.setTag('tagName', 'tagValue')
  scope.setExtra('extraName', 'extraValue')
  Sentry.captureException(err)
})

@mogelbrod Provided the right answer, thanks :)
While we know this is more code to write we think this API is more clear and explicit.
Before the second was basically, pass an object in, "maybe" we pick it up and put in the event.

Closing this since it's not an actual bug.

Was this page helpful?
0 / 5 - 0 ratings