BioDrop: [BUG] needs proper error handling in manage form section

Description

We have lots of AJAX call in pages/account/manage section and we are calling fetch() function. The problem is here that by default the fetch function doesn’t reject the promise if we get back an error status code, in that case, we should reject the promise and throw an actual error and handle the rejected promise.

The downside of not handling a rejected promise in fetch call is that if the request fails for any reason, such as a network error or server-side error, the code does not handle the error gracefully. As a result, the application may not provide appropriate feedback or error handling to the user.

Without proper error handling, it becomes challenging to identify the cause of the issue. Debugging the code and fixing the problem becomes more complex, as there is no specific error message or indication of what went wrong.

To address this issue, it is important to handle rejected promises appropriately. This can involve displaying error messages to the user.

Screenshots

No response

Additional information

want to fix this issue

About this issue

  • Original URL
  • State: closed
  • Created a year ago
  • Comments: 17 (17 by maintainers)

Most upvoted comments

Thank you for the suggestion 👍 I think 1 location of code should be updated and then we can discuss further before implementing it to other areas of the code

Please take a look my draft PR I created. I have improved the error handling functionality and updated in one location of code.

should I implementing it to other areas of the code?

I will ask the other maintainers to take a look, I don’t see a big benefit, it looks very much the same to me and focused on form validation - so wouldn’t work for other http requests 🤔

I think the part we could use is wrapping the http request in a try/catch

@badrivlog sorry I don’t know, it would be great if you correct my code.

I think you should need to know how promise works. (note: please don’t comment issues that are unrelated as this creates extra noise and confusion)

If you need any help- EddieHub Discord might be better https://discord.gg/44dXjyWB

Thanks @badrivlog sure I will take a look and ask the maintainers to also as this is a challenging topic 👍

And that utility function will wrap up the fetch the error handling, and also the conversion to JSON.

But part of that code is specific to form validation and not other requests

Yes we use async/await in our project and we are keen to keep things consistent 👍 thanks for the collaboration everyone, great to see different perspectives 💪

@badrivlog that looks good 👍 I will assign it to you