Js captureException shows as `[object Object]`

In JavaScript, we’re doing

foo.then(
    (bar) => { /* yay success */ },
    (error) => { Raven.captureException(error) }
)

and the message that ends up showing is [object Object].

Given that local variables aren’t captured, this leaves us in the dark.

Digging in a little bit, it looks like raven-js is in the branch of captureException where it thinks our exception doesn’t match isError, so we have some work to do, but . . .

  • Sentry could be more explicit about this, say “hey, you should be using the SDK differently, use captureMessage instead”
  • It’s also possible I want to do something differently where that error originated so that it is an Error object? But [object Object] doesn’t give me much to go on, I’m not sure if that object was one I constructed or if it’s something from AngularJS, etc. So if object doesn’t have a useful toString, can raven-js provide one?

I’m having a similar issue with NavigatorUserMediaError that’s being logged via captureException in an UnhandledPromiseRejection callback.

Seems related to https://github.com/getsentry/raven-js/issues/1008