levibostian / Wendy-Android

Build offline first Android mobile apps. Remove loading screens, perform tasks instantly.
https://levibostian.github.io/Wendy-Android/wendy/
MIT License
64 stars 16 forks source link

What should we do about handling errors? #20

Closed levibostian closed 6 years ago

levibostian commented 6 years ago

When a PendingTask runs, if it fails, there is currently no best pattern for handling that error.

I would prefer to not have wendy involved with this as much as possible because it doens't matter why a task fails to Wendy, just if it did fail.

Go into the example app, when it randomly fails it's pending task, have it also randomly generate a random error of some sort and determine the best way to fix this.

levibostian commented 6 years ago

Closing for now. As I said before, at this time, Wendy only needs to know a task did fail. It doesn't need to know the reason. That is for the developer to take care of.

levibostian commented 6 years ago

The only time that I would see this valuable is after a task fails, having a String available to show to the user in the UI. Since there exists a listener to see the status of a PendingTask, in that status listener it may be able to pass a Throwable or a String along when it does fail, yeah?

levibostian commented 6 years ago

Instead of returning an error after runTask() runs for a specific PendingTask, what I could do is provide a feature to Wendy as an error datastore.

I imagine something like this:

Also, there would be a way to say, "Wendy, this task with task_id of ____ has been resolved. No more error." and Wendy would delete the entry from the database.

My thought process behind this is that:

  1. listeners are temporary. Once the listener gets the error, it's only a matter of time until it disappears. The developer would ask Wendy when the UI refreshes, "Wendy, does this task_id have an error recorded for it that needs resolved?" to indicate if there is an error or not to show and take care of.
  2. This allows the developer to show the error message to the user in the UI and also provide a way for the user to fix the error in the future.

I would also provide a way to query Wendy for all errors of a certain tag and get all errors that exist at the moment. Maybe a developer wants to show a list of errors in the app that the user needs to take care of.

Also, providing an error listener would be nice in the app. Get notified when errors occur so the app could show a notification in the task bar?

levibostian commented 6 years ago

This is done and will be merged into the next release of Wendy.