CompositionErrorContext

Interface

Common
public sealed interface CompositionErrorContext

Provides a way to attach a compose stack trace to a throwable based on a location of compose node in composition. This context is expected to be used by custom node implementations to attach diagnostic compose stack traces to exceptions in passes that are not handled by the Compose runtime (example: measure / layout / draw in Compose UI).

Compose runtime automatically appends information about exceptions that happen in composition and effects.

Functions

public fun Throwable.attachComposeStackTrace(composeNode: Any): Boolean

Attaches a Compose stack trace to a throwable as a suppressed DiagnosticComposeException. Has no effect if:

  • Throwable already contains a suppressed DiagnosticComposeException
  • composeNode is not found in composition
  • composition contains no source information (e.g. in minified builds)

Parameters

composeNodeclosest node to where exception was originally thrown

Returns

true if the exception was attached, false otherwise