SwitchboardResult

data class SwitchboardResult<T>(val success: Boolean, val value: T? = null, val error: String? = null)

The result of a Switchboard SDK operation.

Wraps either a successful value of type T or an error message, providing type-safe error handling without exceptions. Every method on Switchboard returns a SwitchboardResult.

Parameters

T

The type of the value held on success.

Constructors

Link copied to clipboard
constructor(success: Boolean, value: T? = null, error: String? = null)

Types

Link copied to clipboard
object Companion

Properties

Link copied to clipboard
val error: String? = null

The error message if the operation failed, or null on success.

Link copied to clipboard

true if the operation failed.

Link copied to clipboard

true if the operation succeeded.

Link copied to clipboard

Whether the operation succeeded.

Link copied to clipboard
val value: T? = null

The value produced on success, or null if the operation failed.

Functions

Link copied to clipboard

Returns the value on success, or default if the result is an error.

Link copied to clipboard

Returns the value on success, or throws SwitchboardException if the result is an error.