erratum icon indicating copy to clipboard operation
erratum copied to clipboard

Powerful Error Detector for Android

Erratum

Powerful Error Detector for Android

Preview

If an unexpected exception is detected, the exception activity is automatically launched. This activity also contains a button to return to the activity before the exception is thrown.


Download

implementation "land.sungbin:erratum:${version}"

Usage

class App : Application() {
    override fun onCreate() {
        super.onCreate()
        Erratum.setup(application = this)
    }
}

Customize

You can customize the exception activity. In this case, you should make your own exception activity extend ErratumExceptionActivity.

class App : Application() {
    override fun onCreate() {
        super.onCreate()
        Erratum.setup(
            application = this,
            registerExceptionActivityIntent = { thread, throwable, lastActivity ->
                Intent(lastActivity, ErrorActivity::class.java) // should return custom exception activity intent
            }
        )
    }
}

registerExceptionActivityIntent example

Intent(lastActivity, ExceptionActivity::class.java).apply {
    putExtra(ErratumExceptionActivity.EXTRA_EXCEPTION_STRING, throwable.toString())
    putExtra(ErratumExceptionActivity.EXTRA_LAST_ACTIVITY_INTENT, lastActivity.intent)
}

You can use the this method in ErratumExceptionActivity.

val exceptionString: String // get exception message
fun openLastActivity() // Closes the current activity and opens the activity before an exception is thrown.

The style on this component requires your app theme to be Theme.AppCompat (or a descendant)

Use custom ActivityIntent or set the theme of DefaultErratumExceptionActivity like this:

<activity
    android:name="io.github.jisungbin.erratum.DefaultErratumExceptionActivity"
    android:theme="@style/Theme.RunnerBe" /> 

Happy Coding :)