Result

org.llm4s.Result
object Result

Companion object for Result types. Provides utility methods for creating and manipulating Result types. Includes methods for success, failure, fromTry, fromOption, sequence, traverse, and combine. These methods allow users to easily create and handle Result types, providing a consistent and type-safe way to work with results in the LLM4S. Provides a clear and concise API for error handling and result manipulation. Provides methods for creating success and failure results, converting from Try and Option types, sequencing and traversing lists of results, and combining two results into a tuple. This object is designed to be extensible for future requirements, allowing users to add additional utility methods as needed. It provides a consistent and type-safe way to handle results and errors in the LLM4S.

Attributes

Graph
Supertypes
class Object
trait Matchable
class Any
Self type
Result.type

Members list

Value members

Concrete methods

def combine[A, B](ra: Result[A], rb: Result[B]): Result[(A, B)]
def combine[A, B, C](ra: Result[A], rb: Result[B], rc: Result[C]): Result[(A, B, C)]
def failure[A](error: LLMError): Result[A]
def fromBoolean(condition: Boolean, error: LLMError): Result[Unit]

Create Result from boolean condition

Create Result from boolean condition

Attributes

def fromBooleanWithValue[A](condition: Boolean, successValue: A, error: LLMError): Result[A]

Create Result from boolean with custom success value

Create Result from boolean with custom success value

Attributes

def fromFuture[A](future: Future[A])(implicit ec: ExecutionContext): Future[Result[A]]
def fromOption[A](opt: Option[A], error: => LLMError): Result[A]
def safely[A](operation: => A): Result[A]
def sequence[A](results: List[Result[A]]): Result[List[A]]
def success[A](value: A): Result[A]
def traverse[A, B](list: List[A])(f: A => Result[B]): Result[List[B]]
def validateAll[A](items: List[A])(validator: A => Result[A]): Either[List[LLMError], List[A]]

Deprecated methods

def fromTry[A](t: Try[A], finallyBlock: () => Unit): Result[A]

Converts a scala.util.Try[A] into a Result[A], while allowing a custom finallyBlock action.

Converts a scala.util.Try[A] into a Result[A], while allowing a custom finallyBlock action.

Value parameters

finallyBlock

A user-provided finallyBlock function to run after processing.

t

The Try[A] to wrap.

Attributes

Returns

A Result[A] representing success or failure.

Deprecated
[Since version 0.1.10] Use Safety.fromTry or TryOps.toResult with ErrorMapper

Concrete fields

val logger: Logger