Catching and naming a stack trace

In my code I have cases where I try/catch then report, and with my previous exception tracking service I used to configure it like this:

try {
  foo();
} catch(e) {
  exceptionService.error('Caught exception trying to foo', e);
}

In Raven/Sentry, how can I do the same? i.e. I want to “name” my exceptions but still get the benefit of a full stack trace with source map resolution, etc. raven.captureException seems to be the appropriate function to call but how can I override the exception name?

If I’m understanding what you mean by name correctly, you can’t override the exception type/value in Sentry – we explicitly made that choice. You can attach additional metadata if thats what you’re looking for.

What’s the end goal of what you’re trying to achieve?

I’m trying to achieve more meaningfully named “Issues” in the web interface, as well as reduce duplicates.

The “automatic” name given by Sentry for some exceptions can be pretty vague, and it can change between browsers too, making it harder to troubleshoot. So my goal in cases where I have a try/catch and know what the problem is, is that I can give a meaningful name to it rather than having to settle for 2-3 separate issues in Sentry UI, none of which directly describes the problem. It’s literally the first example of the Rollbar give in their Usage guide, for example:

// Caught errors
try {
  doSomething();
} catch (e) {
  Rollbar.error("Something went wrong", e);
}

I think what you might want is to specify ‘culprit’ here. We’re aiming to automatically give them better names, but have just started to roll it out in some of our server side SDKs.

For example, if you wanted it to be the route:

Raven.captureException(err, {culprit: '/foo/:paramID/'})