Closed Aazu07 closed 2 years ago
Thanks for the report!
Could you please clarify what exact line in your snippet is CommonSearchActivityViewModel.java:85
?
Caused by java.lang.ClassCastException: java.lang.InternalError cannot be cast to java.lang.Exception
Usually, such errors indicate a bug in the Kotlin compiler, but it still would be nice to see where java.lang.InternalError
comes from.
As a workaround, if it is really a compiler bug, you could try the following snippet:
public val ceh2: CoroutineExceptionHandler = object : AbstractCoroutineContextElement(CoroutineExceptionHandler), CoroutineExceptionHandler {
override fun handleException(context: CoroutineContext, exception: Throwable) {
isLoading.postValue(false)
GlobalErrorUtils.handleGenericError(
applicationContext = applicationContext,
exception = exception as Exception,
logNonFatalException = true,
displayToastInDebug = true
)
GlobalLoggerUtils.showLog("COUROUTINES", "SocketTimeOutException")
exception.printStackTrace()
job = Job()
}
}
Is it possible to extract self-contained reproducer (snippet I can copy-paste and run in isolation) from your code?
The issue is that its not reproducible at our end, we got this stack trace from Crashlytics. And CommonSearchActivityViewModel.kt class ends before line no 85 so don't know exact line where its happening.
And CommonSearchActivityViewModel.kt class ends before line no 85 so don't know exact line where its happening.
Could you please copy the whole stracktrace to the clipboard and use Analyze -> Stack Trace or Thread dump
action in IDEA, then just click on that frame and see where it navigates?
Line-numbers are messed up because of inline functions, but IDEA/Android Studio should properly map them to the source
Its giving the same line i.e line after end of file. The whole file is here but there are many internal references so you might not be able to create a file and use it.
I have installed kotlin to java decompiler and according to that the line number 85 points to a method in a suspend function. Its some computation on string. I guess that must be causing an Error which is then thrown to CoroutineExceptionHandler.
I am getting an exception from Coroutine exception handler. It say ClassCastException as java.lang.InternalError cannot be cast to java.lang.Exception
I am unable to understand what might cause this.
The code for Coroutine handler is as follows