Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Error handling on Android - 1st Android Athens Meetup

Error handling on Android - 1st Android Athens Meetup

Pavlos-Petros Tournaris

September 22, 2016
Tweet

Other Decks in Technology

Transcript

  1. Error Handling
    Efficient error handling on Android
    https://github.com/Workable/java-error-handler

    View Slide

  2. Error Handling on
    Android
    Vasilis Charalampakis
    Android Software Engineer @ Workable
    [email protected]
    Pavlos-Petros Tournaris
    Android Software Engineer @ Workable
    [email protected]

    View Slide

  3. A common problem in
    Software

    View Slide

  4. 1. Have a default handler for every expected (exceptional,
    common or not) error.
    2. Handle specific errors as appropriate based on where and
    when they occur.
    3. Have a default catch-all handler for unknown errors.
    4. Override any default handler if needed.
    5. Keep our code DRY.

    View Slide

  5. Global VS Specific
    Global
    Handle an error in a common way
    Specific
    Handle an error specifically for a screen

    View Slide

  6. Approach

    View Slide

  7. Solution
    https://github.com/Workable/java-error-handler

    View Slide

  8. API
    ● Initialize
    ● Configure
    ● Execute

    View Slide

  9. Initialize
    ● defaultErrorHandler()
    ● create()
    ● createIsolated()

    View Slide

  10. Configure
    ● on(T, Action)
    ● on(Class extends Exception>, Action)
    ● clear()
    ● bindErrorCode(T, MatcherFactory)
    ● bindErrorCodeClass(Class, MatcherFactory)

    View Slide

  11. Configure
    ● skipFollowing()
    ● skipAlways()
    ● skipDefaults()
    ● always(Action)
    ● otherwise(Action)

    View Slide

  12. Execute
    ● handle(throwable);
    ● run(() -> foo()); // Coming soon…

    View Slide

  13. DEMO
    https://github.com/pavlospt/error-handler-demo

    View Slide

  14. Thanks!

    View Slide