birdofpreyru / react-native-fs

File system access for React Native
https://dr.pogodin.studio/docs/react-native-file-system
Other
160 stars 12 forks source link

uploadFiles and downloadFile have different error handling logic. #56

Open Yupeng-li opened 3 months ago

Yupeng-li commented 3 months ago

Hi,

I noticed that in uploadFiles the http status code that is greater than or equal to 400 is handled internally and is thrown as an error. See code

But downloadFile doesn't do the same. See code.

Also, the Error thrown by uploadFiles has an untyped field result. It's useful, but since it's not typed and is optional, we have to type it by ourselves.

I think it's better that they are consistent and there is a dedicated type of Error for http error responses.

birdofpreyru commented 3 months ago

Yes, I agree. uploadFiles() got recently updated, because of #48 / PR #49, but I had not arrived to update downloadFile() in the similar way. Please, submit a PR if you need it and have capacity to do it.