Skip to content
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

How do we handle exceptions that occur? #29

Open
levibostian opened this issue Feb 16, 2019 · 4 comments
Open

How do we handle exceptions that occur? #29

levibostian opened this issue Feb 16, 2019 · 4 comments
Milestone

Comments

@levibostian
Copy link
Owner

This issue could cover many parts of Teller, but a good place to start is in OnlineRepository.

Teller is a library that performs actions on behalf of the developer. Network calls, saving data to the device, reading data from the device. All of these functions could throw an exception from the developer's code.

When an exception is raised, what do we do? How should Teller handle it?

@levibostian
Copy link
Owner Author

One idea I have is:

  • When observe is called and an exception happens, absorb the exception and pass it down to the Observable returned in observe.

  • When refresh is called and an exception happens, absorb the exception and pass it to the Observable returned in refresh.

Pros:

  • Exception is received by the developer.
  • No changes to the API.

Cons:

  • If Teller has a bug, an exception is raised, it will be passed down to the developer.

@levibostian
Copy link
Owner Author

Great place to start: OnlineRepository, exception thrown in fetch call.

Good way to test this is to go into OnlineRepositoryIntegrationTest, create a test similar to the first fetch success or fail tests but instead of onNext(...), pass in onError().

@levibostian
Copy link
Owner Author

levibostian commented Feb 28, 2019

Another idea:

Ignore Rx completely. Wrap each call to an abstract function of LocalRepository and OnlineRepository in a try/catch block. If an exception is raised, throw it with a message such as "Teller detected an exception in your ___() function" to help.

The nice part about this is to also help with Teller exception handling (when Teller code throws an exception from a bug). When a dev calls a function on Teller code, we can wrap the Teller code in a try/catch block. When an exception is thrown, we can show a message such as "An exception has been thrown within Teller. This is probably a bug. Report that here: github.com/teller/issues/new and paste the below information:....." where the user can give we need to fix it. Exceptions on the dev's code should not interfere because of nested try/catch blocks surrounding dev's code.

This issue couples well with the above paragraph. Debug statements can be generated and saved by Teller and dumped to the console when an exception happens.

@levibostian levibostian added this to the 0.3.0-alpha milestone Mar 15, 2019
@levibostian
Copy link
Owner Author

iOS has this implemented with a try/catch implementation. See code

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant