Added an error handler to the RxBus instance subscription call
This commit is contained in:
parent
c7138c5e22
commit
65250c57f5
1 changed files with 18 additions and 1 deletions
|
@ -147,7 +147,11 @@ abstract class ConnectedActivity : AppCompatActivity(), ServiceConnection {
|
||||||
mDisposable = RxBus.getBusInstance()
|
mDisposable = RxBus.getBusInstance()
|
||||||
.asFlowable()
|
.asFlowable()
|
||||||
.observeOn(AndroidSchedulers.mainThread())
|
.observeOn(AndroidSchedulers.mainThread())
|
||||||
.subscribe { handleIncomingMessage(it) }
|
.subscribe({
|
||||||
|
this.handleIncomingMessage(it)
|
||||||
|
}, {
|
||||||
|
this.handleError(it)
|
||||||
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -161,6 +165,19 @@ abstract class ConnectedActivity : AppCompatActivity(), ServiceConnection {
|
||||||
mCurrentAccount = UserAccount(userId)
|
mCurrentAccount = UserAccount(userId)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Error consumer used to handle potential errors caused by the NetworkService while processing
|
||||||
|
* incoming data.
|
||||||
|
*/
|
||||||
|
private fun handleError(throwable: Throwable){
|
||||||
|
Log.e(TAG, "Error while processing received message. Msg: " + throwable.message)
|
||||||
|
val stack = throwable.stackTrace
|
||||||
|
for (e in stack) {
|
||||||
|
Log.e(TAG, String.format("%s#%s:%d", e.className, e.methodName, e.lineNumber))
|
||||||
|
}
|
||||||
|
Crashlytics.log(Log.ERROR, TAG, "ConnectedActivity reporting error. Msg: ${throwable.message}")
|
||||||
|
}
|
||||||
|
|
||||||
private fun handleIncomingMessage(message: Any?) {
|
private fun handleIncomingMessage(message: Any?) {
|
||||||
if (message is JsonRpcResponse<*>) {
|
if (message is JsonRpcResponse<*>) {
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue