CancelledError

org.llm4s.error.CancelledError
See theCancelledError companion class

Attributes

Companion
class
Graph
Supertypes
trait Product
trait Mirror
class Object
trait Matchable
class Any
Self type

Members list

Type members

Inherited and Abstract types

type MirroredElemLabels <: Tuple

The names of the product elements

The names of the product elements

Attributes

Inherited from:
Mirror
type MirroredLabel <: String

The name of the type

The name of the type

Attributes

Inherited from:
Mirror

Value members

Concrete methods

def apply(operation: String, cause: Option[Throwable]): CancelledError
def attempt[A](operation: String)(body: => Result[A]): Result[A]

Runs body, returning a thrown InterruptedException as Left(CancelledError) with the flag set, and applying whenInterrupted to what it returns. Other exceptions propagate.

Runs body, returning a thrown InterruptedException as Left(CancelledError) with the flag set, and applying whenInterrupted to what it returns. Other exceptions propagate.

Attributes

def fromThrowable(t: Throwable, operation: String): Option[CancelledError]

Some(CancelledError) if t is a cancellation (see isCancellation); otherwise None.

Some(CancelledError) if t is a cancellation (see isCancellation); otherwise None.

Classifies only: it never sets the interrupt flag. The flag belongs to the thread that was interrupted, and the code mapping t may be running on another one - a Future callback on a pool thread, say. Code that itself caught an InterruptedException restores the flag.

Attributes

def isCancellation(t: Throwable): Boolean

Whether t is a cancellation: the current thread is interrupted, or t or one of its causes is an InterruptedException or a ClosedByInterruptException.

Whether t is a cancellation: the current thread is interrupted, or t or one of its causes is an InterruptedException or a ClosedByInterruptException.

The flag test matters on a virtual thread, where an interrupt during a blocking socket read closes the socket and surfaces as an ordinary SocketException. A bare java.io.InterruptedIOException (including SocketTimeoutException) is not enough on its own: OkHttp reports its call timeout as InterruptedIOException("timeout"), and a timeout stays a timeout. It counts only through the flag or an InterruptedException beneath it.

Attributes

def whenInterrupted[A](result: Result[A], operation: String): Result[A]

A failure that ends while the current thread is interrupted is a cancellation.

A failure that ends while the current thread is interrupted is a cancellation.

Attributes