getOrThrow

fun getOrThrow(): T

Returns the success value, or throws for a typed error.

SDK errors carrying operation context throw DockerResultException. Read its DockerResultException.error for the original error, its cause when available, and dockerContext for safe operation metadata. Results created by callers can lack context and throw a plain IllegalStateException whose message includes the error value. Original errors and causes may contain sensitive data.

See also

Throws

If an error contains SDK operation context.

If an error has no operation context.

Samples

try {
    docker.containers.getInfo(id).getOrThrow()
} catch (cancelled: CancellationException) {
    throw cancelled
} catch (failure: Exception) {
    failure.dockerContext?.let { context ->
        println("${context.method} ${context.route}: ${context.stage}, HTTP ${context.httpStatus}")
    }
    throw failure
}