Result

io.scalaland.chimney.partial.Result
See theResult companion trait
object Result

Attributes

See also
Since

0.7.0

Companion
trait
Graph
Supertypes
trait Sum
trait Mirror
class Object
trait Matchable
class Any
Self type
Result.type

Members list

Type members

Classlikes

final case class Errors(errors: NonEmptyErrorsChain) extends Result[Nothing]

Errors case representation.

Errors case representation.

Value parameters

errors

non-empty collection of path-annotated errors

Attributes

Since

0.7.0

Companion
object
Supertypes
trait Serializable
trait Product
trait Equals
trait Result[Nothing]
class Object
trait Matchable
class Any
Show all
object Errors

Attributes

Companion
class
Supertypes
trait Product
trait Mirror
class Object
trait Matchable
class Any
Self type
Errors.type
final case class Value[A](value: A) extends Result[A]

Success value case representation.

Success value case representation.

Type parameters

A

type of success value

Value parameters

value

value of type A

Attributes

Since

0.7.0

Supertypes
trait Serializable
trait Product
trait Equals
trait Result[A]
class Object
trait Matchable
class Any
Show all

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

final def fromCatching[A](value: => A): Result[A]

Converts possibly throwing computation into io.scalaland.chimney.partial.Result.

Converts possibly throwing computation into io.scalaland.chimney.partial.Result.

Type parameters

A

type of successful result

Value parameters

value

computation to run while catching its Exceptions

Attributes

Returns

successful io.scalaland.chimney.partial.Result.Value if computation didn't throw, failed io.scalaland.chimney.partial.Result.Errors with caught Exception if it threw

Since

0.7.0

final def fromCatchingNonFatal[A](value: => A): Result[A]

Converts possibly throwing computation into io.scalaland.chimney.partial.Result by catching only NonFatal Exceptions.

Converts possibly throwing computation into io.scalaland.chimney.partial.Result by catching only NonFatal Exceptions.

Type parameters

A

type of successful result

Value parameters

value

computation to run while catching its NonFatal Exceptions

Attributes

Returns

successful io.scalaland.chimney.partial.Result.Value if computation didn't throw, failed io.scalaland.chimney.partial.Result.Errors with caught Exception if it threw

Since

1.5.0

final def fromEither[A](value: Either[Errors, A]): Result[A]

Converts Either to io.scalaland.chimney.partial.Result, using Errors from Left as failed result.

Converts Either to io.scalaland.chimney.partial.Result, using Errors from Left as failed result.

Type parameters

A

type of successful result

Value parameters

value

Either to convert

Attributes

Returns

successful result if scala.Right, failed result if scala.Left

Since

0.7.0

final def fromEitherString[A](value: Either[String, A]): Result[A]

Converts Either to io.scalaland.chimney.partial.Result, using an error message from Left as failed result.

Converts Either to io.scalaland.chimney.partial.Result, using an error message from Left as failed result.

Type parameters

A

type of successful result

Value parameters

value

Either to convert

Attributes

Returns

successful result if scala.Right, failed result with an error message if scala.Left

Since

0.7.0

final def fromEmpty[A]: Result[A]

Creates failed Result with an empty value error.

Creates failed Result with an empty value error.

Type parameters

A

type of successful result

Attributes

Returns

failed io.scalaland.chimney.partial.Result.Errors containing one io.scalaland.chimney.partial.Error.fromEmptyValue

Since

0.7.0

final def fromError[A](error: Error): Result[A]

Creates failed io.scalaland.chimney.partial.Result from a single error.

Creates failed io.scalaland.chimney.partial.Result from a single error.

Type parameters

A

type of successful result

Value parameters

error

required error

Attributes

Returns

failed io.scalaland.chimney.partial.Result.Errors containing one io.scalaland.chimney.partial.Error

Since

0.7.0

final def fromErrorNotDefinedAt[A](value: Any): Result[A]

Creates failed io.scalaland.chimney.partial.Result from argument for which PartialFunction was not defined.

Creates failed io.scalaland.chimney.partial.Result from argument for which PartialFunction was not defined.

Type parameters

A

type of successful result

Value parameters

value

value for which partial function was not defined

Attributes

Returns

result containing one error

Since

0.7.0

final def fromErrorString[A](message: String): Result[A]

Creates failed io.scalaland.chimney.partial.Result from an error message.

Creates failed io.scalaland.chimney.partial.Result from an error message.

Type parameters

A

type of successful result

Value parameters

message

message to wrap in Error

Attributes

Returns

result containing one error

Since

0.7.0

final def fromErrorStrings[A](message: String, messages: String*): Result[A]

Creates failed io.scalaland.chimney.partial.Result from one error message or more.

Creates failed io.scalaland.chimney.partial.Result from one error message or more.

Type parameters

A

type of successful result

Value parameters

message

required message to wrap in Error

messages

optional messages to wrap in Error

Attributes

Returns

result aggregating all passed errors

Since

0.7.0

final def fromErrorThrowable[W](throwable: Throwable): Result[W]

Creates failed io.scalaland.chimney.partial.Result from Exception that was caught.

Creates failed io.scalaland.chimney.partial.Result from Exception that was caught.

Type parameters

W

type of successful result

Value parameters

throwable

exception

Attributes

Returns

result containing one error

Since

0.7.0

final def fromErrors[A](error: Error, errors: Error*): Result[A]

Creates failed io.scalaland.chimney.partial.Result from one error or more.

Creates failed io.scalaland.chimney.partial.Result from one error or more.

Type parameters

A

type of successful result

Value parameters

error

required head io.scalaland.chimney.partial.Error

errors

optional tail io.scalaland.chimney.partial.Errors

Attributes

Returns

failed io.scalaland.chimney.partial.Result.Errors aggregating all passed io.scalaland.chimney.partial.Errors

Since

0.7.0

final def fromFunction[A, B](f: A => B): A => Result[B]

Converts a function that throws Exceptions into function that returns io.scalaland.chimney.partial.Result.

Converts a function that throws Exceptions into function that returns io.scalaland.chimney.partial.Result.

Type parameters

A

input type

B

output type

Value parameters

f

function that possibly throws

Attributes

Returns

function that catches Exceptions as io.scalaland.chimney.partial.Result.Errors

Since

0.7.0

final def fromOption[A](value: Option[A]): Result[A]

Converts Option to io.scalaland.chimney.partial.Result, using EmptyValue error if None.

Converts Option to io.scalaland.chimney.partial.Result, using EmptyValue error if None.

Type parameters

A

type of successful result

Value parameters

value

Option to convert

Attributes

Returns

successful result if scala.Some, failed result with EmptyValue error if None

Since

0.7.0

final def fromOptionOrError[A](value: Option[A], ifEmpty: => Error): Result[A]

Converts Option to io.scalaland.chimney.partial.Result, using provided Error if None.

Converts Option to io.scalaland.chimney.partial.Result, using provided Error if None.

Type parameters

A

type of successful result

Value parameters

ifEmpty

lazy error for scala.None

value

Option to convert

Attributes

Returns

successful result if scala.Some, failed result with provided error if scala.None

Since

0.7.0

final def fromOptionOrString[A](value: Option[A], ifEmpty: => String): Result[A]

Converts Option to io.scalaland.chimney.partial.Result, using provided error message if None.

Converts Option to io.scalaland.chimney.partial.Result, using provided error message if None.

Type parameters

A

type of successful result

Value parameters

ifEmpty

lazy error message for scala.None

value

scala.Option to convert

Attributes

Returns

successful result if scala.Some, failed result with provided error message if scala.None

Since

0.7.0

final def fromOptionOrThrowable[A](value: Option[A], ifEmpty: => Throwable): Result[A]

Converts Option to Result, using provided Throwable if None.

Converts Option to Result, using provided Throwable if None.

Type parameters

A

type of successful result

Value parameters

ifEmpty

lazy error for scala.None

value

Option to convert

Attributes

Returns

successful result if scala.Some, failed result with provided Throwable if scala.None

Since

0.7.0

final def fromPartialFunction[A, B](pf: PartialFunction[A, B]): A => Result[B]

Converts a partial function that throws Exceptions into function that returns io.scalaland.chimney.partial.Result.

Converts a partial function that throws Exceptions into function that returns io.scalaland.chimney.partial.Result.

Type parameters

A

input type

B

output type

Value parameters

pf

partial function that possibly throws

Attributes

Returns

function that catches Exceptions and arguments without defined value as io.scalaland.chimney.partial.Result.Errors

Since

0.7.0

final def fromTry[A](value: Try[A]): Result[A]

Converts Try to io.scalaland.chimney.partial.Result, using Throwable from Failure as failed result.

Converts Try to io.scalaland.chimney.partial.Result, using Throwable from Failure as failed result.

Type parameters

A

type of successful result

Value parameters

value

scala.util.Try to convert

Attributes

Returns

successful result if scala.util.Success, failed result with Throwable if scala.util.Failure

Since

0.7.0

final def fromValue[A](value: A): Result[A]

Creates successful io.scalaland.chimney.partial.Result from a precomputed value.

Creates successful io.scalaland.chimney.partial.Result from a precomputed value.

Type parameters

A

type of successful value

Value parameters

value

successful value to return in result

Attributes

Returns

successful io.scalaland.chimney.partial.Result.Value

Since

0.7.0

final def map2[A, B, C](resultA: Result[A], resultB: => Result[B], f: (A, B) => C, failFast: Boolean): Result[C]

Combines 2 io.scalaland.chimney.partial.Results into 1 by combining their successful values or aggregating errors.

Combines 2 io.scalaland.chimney.partial.Results into 1 by combining their successful values or aggregating errors.

Type parameters

A

first successful input type

B

second successful input type

C

successful output type

Value parameters

f

function combining 2 successful input values into successful output value

failFast

whether conversion should stop at first failed element or should it aggregate errors from both Results

resultA

first Result

resultB

second Result

Attributes

Returns

successful io.scalaland.chimney.partial.Result.Value of combination if both io.scalaland.chimney.partial.Results were successful, failed io.scalaland.chimney.partial.Result.Errors if at least one of io.scalaland.chimney.partial.Results were failure

Since

0.7.0

final def product[A, B](resultA: Result[A], resultB: => Result[B], failFast: Boolean): Result[(A, B)]

Combines 2 io.scalaland.chimney.partial.Results into 1 by tupling their successful values or aggregating errors.

Combines 2 io.scalaland.chimney.partial.Results into 1 by tupling their successful values or aggregating errors.

Type parameters

A

first successful input type

B

second successful input type

Value parameters

failFast

whether conversion should stop at first failed element or should it aggregate errors from both io.scalaland.chimney.partial.Results

resultA

first io.scalaland.chimney.partial.Result

resultB

second io.scalaland.chimney.partial.Result

Attributes

Returns

successful io.scalaland.chimney.partial.Result.Value with a tuple if both io.scalaland.chimney.partial.Results were successful, failed io.scalaland.chimney.partial.Result.Errors if at least one of io.scalaland.chimney.partial.Result were failure

Since

0.7.0

final def sequence[M, A](it: Iterator[Result[A]], failFast: Boolean)(implicit fac: Factory[A, M]): Result[M]

Converts an scala.collection.Iterator containing io.scalaland.chimney.partial.Results into a io.scalaland.chimney.partial.Result with selected collection of successful values.

Converts an scala.collection.Iterator containing io.scalaland.chimney.partial.Results into a io.scalaland.chimney.partial.Result with selected collection of successful values.

Type parameters

A

type of successful values in Results

M

type of output - output collection of output element

Value parameters

fac

factory of output type

failFast

whether conversion should stop at first failed element conversion or should it continue to aggregate all errors

it

iterator with Results to aggregate

Attributes

Returns

result with user-selected collection of converted elements if all conversions succeeded, result with conversion errors if at least one conversion failed

Since

0.7.0

final def traverse[M, A, B](it: Iterator[A], f: A => Result[B], failFast: Boolean)(implicit fac: Factory[B, M]): Result[M]

Converts an scala.collection.Iterator of input type into selected collection of output type, aggregating errors from conversions of individual elements.

Converts an scala.collection.Iterator of input type into selected collection of output type, aggregating errors from conversions of individual elements.

Type parameters

A

type of elements of input

B

type of elements of output

M

type of output - output collection of output element

Value parameters

f

function converting each individual element to Result

fac

factory of output type

failFast

whether conversion should stop at first failed element conversion or should it continue to aggregate all errors

it

iterator with elements to convert

Attributes

Returns

io.scalaland.chimney.partial.Result.Value with user-selected collection of converted elements if all conversions succeeded, io.scalaland.chimney.partial.Result.Errors with conversion errors if at least one conversion failed

Since

0.7.0