ErrorBoundary
Deprecated
This implementation is deprecated. Please use the new implementation from soil-reacty module instead.
Replace with
import soil.plant.compose.reacty.ErrorBoundary
ErrorBoundary(modifier, fallback, onError, onReset, state, content)
Wrap an ErrorBoundary around other Catch composable functions to catch errors and render a fallback UI.
Note: Typically, this function is defined at the top level of a screen and used for default error handling. Do not propagate errors from ErrorBoundary to higher-level components since the error state is managed by state. Instead, it's recommended to catch and handle domain-specific exceptions within Catch content blocks.
Usage:
ErrorBoundary(
modifier = Modifier.fillMaxSize(),
fallback = {
ContentUnavailable(
error = it.err,
reset = it.reset,
modifier = Modifier.matchParentSize()
)
},
onError = { e -> println(e.toString()) },
onReset = rememberQueriesErrorReset()
) {
Suspense(..) {
val query = rememberGetPostsQuery()
..
Catch(query) { e ->
// You can also write your own error handling logic.
if (e is DomainSpecificException) {
Alert(..)
return@Catch
}
Throw(e)
}
}
}
Parameters
The modifier to be applied to the layout.
The fallback UI to render when an error is caught.
The callback to be called when an error is caught.
The callback to be called when the reset button is clicked.
The state of the ErrorBoundary.
The content of the ErrorBoundary.