react-native-pdf
react-native-pdf copied to clipboard
Improvement request: add http status code and response body to error object in onError callback
react-native version
0.63.2
react-native-pdf version
6.2.0
platform: both
Steps to reproduce
- display pdf with the following code
<Pdf
source={{ uri: 'back-end url here' }}
onError={(e) => {
console.log(e);
}}
/>
- return ( or simulate with http proxy ) from the back-end error with code status like 500 (internal server error), 403/401 ( that means session is expired ), etc.
Actual result:
in case of http request aborted (ios) error message is:
The operation couldn’t be completed. (kCFErrorDomainCFNetwork error 303.)
in case of server return 403 code status with ( for e.g. ) json body ( {"error": "SessionExpired" } ) error message is:
Load pdf failed. path=/Users/username/Library/Developer/path_to_pdf.pdf
Expected result:
error
object will have http status code and http response body in case of error so the app will be able to correctly handle different kind of responses from the server. E.g. logout the user if session was expired and server respond with 403/401 code status.
Same issue when using base 64 encoded uri
I'm a little surprised to see this still hasn't been addressed after so long. I too would like to be able to react to whether onError has been caused by a 404 vs a 401 or a 500. It seems a little odd that I can't figure this out from the cryptic error messages provided.