Rethrow error (with added data) in catch when getting token (catch of await (await instanceProm)(tokenReq))
Closed this issue · 1 comments
When debugging a connection problem I noticed that when an error is thrown while getting a token (like a 401) then only the full axios error is replaced by a new error with only the text sap-cf-axios: Error while getting token ${tokenReq.method} ${tokenReq.url}
. This makes catching errors in my own code rather difficult. It would be nice if the orignal error was rethrown with some added data.
A bit like this:
const cfErr = {
...err,
'sap-cf-axios': {
message: 'sap-cf-axios: Error while getting token',
tokenMethod: tokenReq.method,
tokenUrl: tokenReq.url
}
}
throw cfErr
I would have made a pull request but I noticed that the code in this repo is behind the actual code in the npm module (missing logAxiosError, still having a console.error instead of the throw (sap-cf-axios: Error while getting token ${tokenReq.method} ${tokenReq.url}
);, etc.
Thanks Pieter.
I've added this.
kr,
Joachim