You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When doing getTransactionInfo( tId ) - getting unhandled rejection:
UnhandledPromiseRejectionWarning: TypeError: Cannot read property 'data' of undefined
at get (path\node_modules\node-qiwi-api\lib\asyncApi.js:724:34)
at processTicksAndRejections (internal/process/task_queues.js:97:5)
at async init (path\index.js:101:13)
Which goes from this fn:
async function get(options) {
options.headers = headers;
try {
var result = await axios.get(options.url, options);
console.log(result)
if (result.data.errorCode != undefined)
throw result.data;
return result.data;
}
catch (error) {
throw error.response.data;
}
}
However if we check error object getting into catch part - it's completely normal response, with fields:
errorCode: 0,
error: null
So the error in comparing 0 with undefined, getting true here, then throwing error.
Line 718
The fix would be like this:
if (result.data.errorCode) {
//
}
When it's 0 (false) it won't trigger if.
Any other err code will.
or
if (result.data.error != null) {
//
}
Same error check method is used in lines
736
754
771
788
Also comparisons like this error.message != undefined
on lines
703
677
May also cause problem at some point ( or at least it's senseless, because of the same reason described above )
Despite I didn't get any missthrows on these lines by now,
I recommend you to look into them more closely and probably change the same way.
The text was updated successfully, but these errors were encountered:
AKJee
changed the title
Wrong error response catching
Wrong error catching method
Oct 21, 2020
When doing getTransactionInfo( tId ) - getting unhandled rejection:
Which goes from this fn:
However if we check error object getting into catch part - it's completely normal response, with fields:
So the error in comparing 0 with undefined, getting true here, then throwing error.
Line 718
The fix would be like this:
When it's 0 (false) it won't trigger if.
Any other err code will.
or
Same error check method is used in lines
736
754
771
788
Also comparisons like this
error.message != undefined
on lines
703
677
May also cause problem at some point ( or at least it's senseless, because of the same reason described above )
Despite I didn't get any missthrows on these lines by now,
I recommend you to look into them more closely and probably change the same way.
The text was updated successfully, but these errors were encountered: