Closed beryasar closed 2 years ago
Can you give me a code example? Because in my tests, I clearly see the error object in case of 400.
Here is my code:
// url coming another function await (async () => { const downloader = new Downloader({ url: url, directory: "./" }); try { await downloader.download(); console.log("All done"); } catch (error) { console.log("Download failed", error); } })();
In this code sample, when status is 400, I get a try catch as expected, but I also want to reach the response body in this try catch because I want to reach the error message.
When i throw the error object, i do not make a reference to the request/response objects. You're probably used to having it from Axios, It's actually a good idea to implement this. Currently i don't see any way to access those objects when an error is emitted. But why do you actually need it?
I need this because they have put multiple error messages for 400 error code in the API I am using.
I've added a reference to node's response object, to the Error. Manual handling is still needed
When the request returns 400, I can't reach the detailed message of the error coming from the API? Is it possible for me to access this message somehow?