On error, it prints the message: Request failed with status code 400
Here is the same error Obj saved to file (writeFileSync)
{
"message": "Request failed with status code 400",
"name": "Error",
"stack": "Error: Request failed with status code 400\n at createError (/Users/steven/Desktop/Programming/node_modules/axios/lib/core/createError.js:16:15)\n at settle (/Users/steven/Desktop/Programming/node_modules/axios/lib/core/settle.js:17:12)\n at IncomingMessage.handleStreamEnd (/Users/steven/Desktop/Programming/node_modules/axios/lib/adapters/http.js:237:11)\n at IncomingMessage.emit (events.js:205:15)\n at IncomingMessage.EventEmitter.emit (domain.js:471:20)\n at endReadableNT (_stream_readable.js:1154:12)\n at processTicksAndRejections (internal/process/task_queues.js:84:9)",
"config": {
"url": "https://aaaaaaa.com",
"method": "put",
"data": "",
"headers": { "Accept": "application/json, text/plain, */*", "Content-Type": "application/json", "User-Agent": "axios/0.19.0", "Content-Length": 345 },
"auth": { "username": "api_1", "password": "" },
"transformRequest": [null],
"transformResponse": [null],
"timeout": 0,
"xsrfCookieName": "XSRF-TOKEN",
"xsrfHeaderName": "X-XSRF-TOKEN",
"maxContentLength": -1
}
}
I also send the error object err to sentry. But when it shows up in sentry it’s completely missing any of the error objects values which I passed across eg they’re in the file but not in Sentry. Which is not very helpful, compared to just saving the error object to a file. This is currently happening with all errors I pass to Sentry.
I think you are mostly interested in capturing the config field which you can do with using contexts: https://docs.sentry.io/platforms/javascript/#adding-context. I’d strongly recommend splitting the fields on this object for better event grouping and searching when setting on the context (so add headers, username, url and method as separate fields and anything else as unstructured extra data).
You may also be interested in the Express Integration which captures a bunch of context and breadcrumbs automatically.
hey @BYK thanks for the response, I guess my frustration is I don’t always know what type of error I’m going to get… eg it may or may not have a config attribute. I also appreciate how adding context would help with advanced filtering but sometimes you just want to capture an error quickly (such as writing it to a file) and I dont want to have to spend time setting up the context. As such I’m passing the whole error object to Sentry and would expect to see it in the UI.
In a typical app dev cycle I’d typically just console.log the error message and then later I’d want to start capturing more details if I hit a harder bug. My aim was to be able to just replace that line with
> Sentry.captureException(err)
so I’d have the full details logged and recorded for me. But it sounds like I have to fully understand all of the elements of the potential error object and then create a custom context for it. Which is a lot more long winded than just saving the error object to a file.