How to make sentry show line where exception was thrown not caught?

I’m using node to capture a sentry exception. But it seems to show me the line where the exception was caught – not where the exception was shown? Is there anyway to make it show me where the exception was thrown?

Thanks for any help!

What is the source of the error you’re trying to capture? Are you trying to report the exception that was caught on lines 35/36? Or is there a parameter e passed into this function?

My guess is that the actual error isn’t getting passed into captureException. If you look at the source for captureException it will create a new Error if one isn’t passed in, or the item passed in isn’t an Error. This would result in a stack trace to where you captured the Error and not where the Error was first thrown.

Can you post the full source of your method? Also you could try renaming the Error being ignoring on like 35 (in the screenshot) to something other than e.

Hi boushley thanks for the response!

This does sound like a likely source of the problem… maybe the object I’m passing captureException is not really an Error object (although that was my intention).

I am not trying to catch the exception on line 35/36. Rather I have a helper function I wrote called captureException that

  • attempts to log the error to slack directly
  • then attempts to capture the exception with raven
    (my goal of this helper function was to make it easy to sub in a different error service if I needed to, as this was my first project using sentry).

The codebase I am working on is completely open source, here: https://github.com/CallParty/CallParty

my captureException helper function is here: https://github.com/CallParty/CallParty/blob/master/backend/app/utilities/logHelper.js#L28

… maybe I can put some kind of test in which checks the type of e and logs it (that way I can discover where in my app I’m calling captureException without a real error object)