In Compose HTML, I want to add central error handl...
# compose-web
h
In Compose HTML, I want to add central error handling so that I no longer get the 'Uncaught runtime errors' page, but can show a neat error message. Anyone an idea how to implement this? (edited)
Currently, I do something like:
Copy code
val localDi = localDI()
window.asDynamic().onerror = { message: dynamic, _: dynamic, _: dynamic, _: dynamic, _: dynamic ->
    handleError(localDi, message)
    true 
}
Copy code
fun handleError(di:DI, message:String) {

    // store message in sessionStorage
    ...

 
    CoroutineScope(Dispatchers.Main).launch {
        // save data to server or indexedD
        ...

        // redirect to error page
        window.location.href = "/error.html"
    }
}
But this will still show the default "Uncaught runtime errors" page for a second or so. It would be nice if we could overrule the default runtime error handling of Compose HTML.