WikiEducationFoundation / WikiEduDashboard

Wiki Education Foundation's Wikipedia course dashboard system
https://dashboard.wikiedu.org
MIT License
392 stars 631 forks source link

Fix error handling in ArticleFinder #5945

Closed Abishekcs closed 2 months ago

Abishekcs commented 2 months ago

closes #5942

What this PR does

Fix mishandled errors in ArticleFinder.

Cause of Bug (Why There Was an Empty Error Message)

It's possible that the API sometimes returned a plain error message as a string instead of an error object. Since the code was designed to handle only error objects, it couldn't process the plain string, leading to an empty error message.

Screenshots

Before:

Rapid click on 'More Results':

https://github.com/user-attachments/assets/fabb1783-1ee1-4ac9-8c2e-c3d395dadaae

Rapid click on 'More Results' & Network Slow or Disconnected:

https://github.com/user-attachments/assets/4678554f-7982-4efc-9352-5652f360b48b

After:

Rapid click on 'More Results':

https://github.com/user-attachments/assets/250be9be-f43f-4364-8661-a923e364fcd5

Rapid click on 'More Results' & Network Slow or Disconnected:

https://github.com/user-attachments/assets/aa6f82b2-964f-439f-b063-f08821bacc02

Open questions and concerns

Previously, when fetch requests for articles failed, the system displayed an error message for each failed article. This could result in the user's screen becoming cluttered with multiple error messages. To improve the user experience, I've modified the system to show a single error notification for any number of failed article fetches, whether it's one or many. The before and after screenshots below illustrate this change.

Before:

Before (Network Slow or Disconnected)

After:

After (Network Slow or Disconnected)