RootForTest.UncaughtExceptionHandler


An optional error handler that can be set to catch exceptions thrown during the layout, draw, and teardown phases of the associated composition. If an exception is thrown to this callback, the composition is already in an unrecoverable state and must be abandoned. Tests may choose to catch exceptions to forward or process them differently. By default, no exception handler is present and exceptions are thrown on the composer's thread, which may cause the process to crash.

This interface should generally not be used in production, and is intended for error routing or introspection rather than true error recovery.

Summary

Public functions

Unit

Invoked for testing infrastructure to be able to redirect an exception t that occurred during the layout, measure, or draw phase of the underlying view.

Cmn

Public functions

onUncaughtException

fun onUncaughtException(t: Throwable): Unit

Invoked for testing infrastructure to be able to redirect an exception t that occurred during the layout, measure, or draw phase of the underlying view. When this function is invoked, the associated composition is in an unrecoverable state. The original exception may be re-thrown to propagate it.

If this callback swallows an exception to prevent a crash, you should expect other follow-up exceptions to be directed here as more operations are executed on the degenerate composition. The first exception passed to this callback is likely to be the only useful exception.

Parameters
t: Throwable

The exception thrown by the composition hierarchy during the layout, measure, or draw phase of the associated view.