Send status code with 'Hint' using axios

Hey there,

I’m currently building a global error handler with Sentry and I use the beforeSent method. I realized that the hint parameter does not include the status code I got back from the server. I use axios as HTTP library. I would like show a message on the screen that is dependent on the status code. It might be an axios thing but afaik it always holds the status code in the response-object. My hint-object looks like this:

   {
   "originalException":{
      "message":"Request failed with status code 404",
      "name":"Error",
      "fileName":"http://localhost:8080/static/js/chunk-vendors.js line",
      "lineNumber":16,
      "columnNumber":15,
      "stack":"MY_STACK",
      "config":{
         "url":"v1/MY-URL",
         "method":"get",
         "headers":{
            "Accept":"application/json, text/plain, */*",
            "Authorization":"MY_JWT"
         },
         "params":{
            "page":0,
            "size":9999,
         },
         "baseURL":"/",
         "transformRequest":[
            null
         ],
         "transformResponse":[
            null
         ],
         "timeout":0,
         "xsrfCookieName":"XSRF-TOKEN",
         "xsrfHeaderName":"X-XSRF-TOKEN",
         "maxContentLength":-1,
         "maxBodyLength":-1
      }
   },
   "syntheticException":{
      
   },
   "event_id":"MY_EVENT_ID"
}

Example:

if (hint?.originalException?.status === 404) {
  showNotificaiton({ name: 'Resource not found', type: 'error', duration: 3000 })
}

Thanks a lot!

Has nobody an answer?

Push. No one?

You almost had it

hint?.originalException?.isAxiosError && hint?.originalException?.response?.status