Setting error message other than url messes up transaction name and stack trace for API error #6469
Unanswered
ThomasAitken
asked this question in
Q&A
Replies: 1 comment 3 replies
-
Update: if I simply include the url somewhere in the custom message, then the transaction name and stack trace details work fine again automatically. Can someone tell me the logic that determines this? This all feels very weird and non-intuitive! |
Beta Was this translation helpful? Give feedback.
3 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
I'm just trying to understand Sentry better. It seems like it should be possible to do what I'm trying to do but every thing I try raises new complications and the source code seems to be a labyrinth.
Using
@sentry/react
, I'm intercepting AxiosErrors and using a custom error class to try to set a custom message and name. In case this is relevant, this is happening in the context of a Webpack bundle. One sample:Here
CustomHTTPValidationError
extendsCustomBaseError
which extendsError
and in its constructor sets the error message:If
message
here iserr.config.url
, then the Sentry error header looks like:CustomHTTPValidationError CustomHttpValidationError: (my/api/url/path)
my/api/url/path
And the stack trace recognises the nature of the error:
my/api/url/path in CustomHTTPValidationError
If I instead pass a custom message into the Error constructor (rather than the API url), then the Sentry error header looks like:
CustomHTTPValidationError /path/to/webpack/bundle/file.js
My custom message here
Note that the transaction name no longer refers to my custom error class and the API url. Furthermore, the stack trace also just locates the error in terms of the webpack bundle file, rather than locating it in terms of my custom error class. If you look at the first sample, when I comment out the code including the scope method
setTransactionName
, then I'm able to make the error header look how I want it to:CustomHTTPValidationError CustomHttpValidationError: (my/api/url/path)
My custom message here
In this case, "CustomHttpValidationError: (my/api/url/path)" is the transaction name I had to set manually via
setTransactionName
.Even though I now have the error header looking like I want it to, the stack trace only references the webpack bundle file, rather than locating it in terms of my custom error class.
How can I get all the following to work:
Beta Was this translation helpful? Give feedback.
All reactions