-
-
Notifications
You must be signed in to change notification settings - Fork 15
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
uploadFiles() doesn't return error status code or message in the promise catch()-method. #48
Comments
Hmm... if look through the native code, It should be investigated, but |
Thanks for looking into it. I did too. I found that in the |
Thanks for your donation @Crare , I'll mention you as a sponsor in the repo's README sometime later. I believe the file/line you mention just propagates the error message, but does not generate it; and looking at the code, I guess, it is supposed that if it is just a server-side error there should be no exception there, it will just go the first branch of if-condition that do include The actual error should be coming from here, meaning the react-native-fs/android/src/main/java/com/drpogodin/reactnativefs/Uploader.kt Lines 26 to 32 in b45a9c2
upload() method, and go through it step-by-step, to see at what point it throws and why. The error reads like it fails when handling local file access, rather than because server responded with error code.
|
Hi! I found where the problem is finally by debugging that Should I make a PR for this or do you have time to look into it? This was just a fix to Android side. I need to check iOS side too. change:
|
not sure if it should throw exception and go to promise.reject in that case if statusCode is not successful type or just check the result statuscode in the JS-code side. the example handles the statusCode in the promise.resolve:
|
Ok, I see, I was wrong in my previous message, if server responds with an error status code the attempt to access input stream throws, as you say, and the library rejects the Here are details from HttpURLConnection docs: Great if your little patch resolves it for you, but for the library I guess it needs somewhat extra work and more complex solution: I guess, it should keep the past behavior and reject JS-side promise on such error, but it should indeed expose additional details from |
I don't quite have time to seriously look into all this right now, and presumably I'll be busy with higher priority stuff the next few weeks. I'd say, perhaps, use https://www.npmjs.com/package/patch-package to patch it directly in your project, copy/paste the patch into here, so I can refer to it whenever I have time, and then sometime later I probably look into adopting it into the library, perhaps with some modifications of the behavior, but keeping the actual functionality you need. |
I checked iOS-side now, it already works in that way that it returns resolve with the statusCode and message in server error cases. So now they would be consistent with iOS and Android side. I don't know how to test the Windows-side. |
Cool! Then it makes the life easier... still will need to ensure it is covered by tests in the example app, and correctly documented in README. |
I have tried to handle file upload in the backend and return error in some business case validation, but I can't get the error result to show in the uploadFiles catch-method. It only gives same generic error everytime no matter what:
I've changed the url. but upload works, but error handling is non existent. I can't handle and show specific error to the user why their upload didn't work.
and on JSON.stringify:
The text was updated successfully, but these errors were encountered: