Skip to content

Instantly share code, notes, and snippets.

@iblinov65apps
Created March 6, 2018 06:48
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save iblinov65apps/39715dcc98ff787022310a7e9f328701 to your computer and use it in GitHub Desktop.
Save iblinov65apps/39715dcc98ff787022310a7e9f328701 to your computer and use it in GitHub Desktop.
package ru.alexfitness.presentation.core.utils;
import android.support.annotation.StringRes;
import ru.alexfitness.presentation.core.view.ErrorView;
public interface ErrorHandlerCreator {
Builder newBuilder(ErrorView errorView, Throwable throwable);
Builder defaultBuilder(ErrorView errorView, Throwable throwable);
interface ErrorHandler {
void handleErrors();
}
interface Builder {
Builder checkNetworkErrors();
Builder checkApiExceptions();
Builder apiCodeExceptionListener(OnApiCodeExceptionListener listener);
Builder anotherThrowableListener(OnAnotherThrowableListener listener);
Builder anyThrowableListener(OnAnyThrowableListener listener);
Builder defaultError(@StringRes int defaultErrorRes);
ErrorHandler build();
}
interface OnApiCodeExceptionListener {
void onApiCodeException(int code);
}
interface OnAnotherThrowableListener {
/**
* Tries to handle throwable. If not, throwable is handled by standard way.
* @param throwable Throwable
* @return Whether or not throwable was handled.
*/
boolean handleThrowable(Throwable throwable);
}
interface OnAnyThrowableListener {
void handleThrowable(Throwable throwable);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment