I have a throwable object and I want to print its stacktrace in the logcat with an "Log.e" logging level (error). My method is throwing an exception, but the stacktrace is printed as a warning.
Here is My Code :
@Throws(RuntimeException::class)
fun throwErrorIfNotHttp (e: Throwable) {
if (e is HttpException) {
val code = e.code()
} else if (e is SocketTimeoutException) {
Log.e("time out", "time out")
} else if (e is IOException) {
Log.e("File error", "file error")
} else {
throw RuntimeException(e) // This should appear as error
}
}
Here is the image of exception .
Edit
My Extension Function:
fun <T> Observable<Response<T>>.makeRequest(
context: Context,
executeOnError: ((Any?) -> Unit)? = null, executeOnSuccess: (T?) -> Unit
): Disposable? {
val disposable: Disposable = this
.subscribeOn(Schedulers.io())
.observeOn(AndroidSchedulers.mainThread())
.subscribe({
if (it.isSuccessful) {
executeOnSuccess(it?.body())
} else {
val error = getExceptionFromResponse(it, context)
handleError(error, context)
}
}, {
throwErrorIfNotHttp(it)
})
return disposable
}
How can I make it to show it in error tab instead of warning tab ?

printStackTrace()error handler there.