Skip to content

Client-side typesafe Spine schema usageopensavvy.spine.clienthandle

handle

inline suspend fun <Out : Any, O, F1> SpineResponse<Out, FailureSpec.Or<FailureSpec.Never, FailureSpec.ByCode<F1>>>.handle(handle1: (F1) -> O, transform: (Out) -> O): O

Exhaustively handle failures.

If the request is succesful, transform is called. If the request fails with the error F1, handle1 is called.

To learn more about failures, see the documentation.

Example

client.request(Api / Users / Users.create).handle(
    handle1 = { println("Failed with $it") },
) { println("Created: " + it) }

See also

inline suspend fun <Out : Any, O, F1, F2> SpineResponse<Out, FailureSpec.Or<FailureSpec.Or<FailureSpec.Never, FailureSpec.ByCode<F1>>, FailureSpec.ByCode<F2>>>.handle(handle1: (F1) -> O, handle2: (F2) -> O, transform: (Out) -> O): O

Exhaustively handle failures.

If the request is succesful, transform is called. If the request fails with an error, the corresponding handler is called.

To learn more about failures, see the documentation.

Example

client.request(Api / Users / Users.create).handle(
    handle1 = { println("Failed with $it") },
) { println("Created: " + it) }

See also

inline suspend fun <Out : Any, O, F1, F2, F3> SpineResponse<Out, FailureSpec.Or<FailureSpec.Or<FailureSpec.Or<FailureSpec.Never, FailureSpec.ByCode<F1>>, FailureSpec.ByCode<F2>>, FailureSpec.ByCode<F3>>>.handle(handle1: (F1) -> O, handle2: (F2) -> O, handle3: (F3) -> O, transform: (Out) -> O): O

Exhaustively handle failures.

If the request is succesful, transform is called. If the request fails with an error, the corresponding handler is called.

To learn more about failures, see the documentation.

Example

client.request(Api / Users / Users.create).handle(
    handle1 = { println("Failed with $it") },
) { println("Created: " + it) }

See also

inline suspend fun <Out : Any, O, F1, F2, F3, F4> SpineResponse<Out, FailureSpec.Or<FailureSpec.Or<FailureSpec.Or<FailureSpec.Or<FailureSpec.Never, FailureSpec.ByCode<F1>>, FailureSpec.ByCode<F2>>, FailureSpec.ByCode<F3>>, FailureSpec.ByCode<F4>>>.handle(handle1: (F1) -> O, handle2: (F2) -> O, handle3: (F3) -> O, handle4: (F4) -> O, transform: (Out) -> O): O

Exhaustively handle failures.

If the request is succesful, transform is called. If the request fails with an error, the corresponding handler is called.

To learn more about failures, see the documentation.

Example

client.request(Api / Users / Users.create).handle(
    handle1 = { println("Failed with $it") },
) { println("Created: " + it) }

See also

inline suspend fun <Out : Any, O, F1, F2, F3, F4, F5> SpineResponse<Out, FailureSpec.Or<FailureSpec.Or<FailureSpec.Or<FailureSpec.Or<FailureSpec.Or<FailureSpec.Never, FailureSpec.ByCode<F1>>, FailureSpec.ByCode<F2>>, FailureSpec.ByCode<F3>>, FailureSpec.ByCode<F4>>, FailureSpec.ByCode<F5>>>.handle(handle1: (F1) -> O, handle2: (F2) -> O, handle3: (F3) -> O, handle4: (F4) -> O, handle5: (F5) -> O, transform: (Out) -> O): O

Exhaustively handle failures.

If the request is succesful, transform is called. If the request fails with an error, the corresponding handler is called.

To learn more about failures, see the documentation.

Example

client.request(Api / Users / Users.create).handle(
    handle1 = { println("Failed with $it") },
) { println("Created: " + it) }

See also

inline suspend fun <Out : Any, O, F1, F2, F3, F4, F5, F6> SpineResponse<Out, FailureSpec.Or<FailureSpec.Or<FailureSpec.Or<FailureSpec.Or<FailureSpec.Or<FailureSpec.Or<FailureSpec.Never, FailureSpec.ByCode<F1>>, FailureSpec.ByCode<F2>>, FailureSpec.ByCode<F3>>, FailureSpec.ByCode<F4>>, FailureSpec.ByCode<F5>>, FailureSpec.ByCode<F6>>>.handle(handle1: (F1) -> O, handle2: (F2) -> O, handle3: (F3) -> O, handle4: (F4) -> O, handle5: (F5) -> O, handle6: (F6) -> O, transform: (Out) -> O): O

Exhaustively handle failures.

If the request is succesful, transform is called. If the request fails with an error, the corresponding handler is called.

To learn more about failures, see the documentation.

Example

client.request(Api / Users / Users.create).handle(
    handle1 = { println("Failed with $it") },
) { println("Created: " + it) }

See also