public static ChatError getError(int code, String message){ return new ChatError(code, message); }
@Override public String toString() { return String.format("ChatError, Code: %s, CoreMessage: %s, Tag: %s", code, getMessage(), tag); } }
public Completable authenticateWithCachedToken() { return Single.create((SingleOnSubscribe<FirebaseUser>) emitter-> { if (isAuthenticating()) { emitter.onError(ChatError.getError(ChatError.Code.AUTH_IN_PROCESS, "Cant execute two auth in parallel")); } else { setAuthStatus(AuthStatus.CHECKING_IF_AUTH); FirebaseUser user = FirebaseAuth.getInstance().getCurrentUser(); if (user != null) { emitter.onSuccess(user); } else { emitter.onError(ChatError.getError(ChatError.Code.NO_AUTH_DATA, "No auth bundle found")); } } }) .flatMapCompletable(this::authenticateWithUser) .doOnTerminate(this::setAuthStateToIdle) // Whether we complete successfully or not, we set the status to idle .subscribeOn(Schedulers.single()); }
e.onError(ChatError.getError(ChatError.Code.NULL, "Value is blank")); return;
public static ChatError getNoPathError() { return new ChatError(Code.NO_PATH); }
}).addOnFailureListener(error -> e.onError(ChatError.getError(ChatError.Code.FIREBASE_STORAGE_EXCEPTION, error.getMessage())));
public static ChatError getError(int code) { return new ChatError(code); }
public static ChatError getExceptionError(Exception e, String message){ return new ChatError(Code.EXCEPTION, message, e); }
public static ChatError getExceptionError(Exception e){ return new ChatError(Code.EXCEPTION, e.getMessage(), e); }
return new ChatError(code, errorMessage, error);