All Downloads are FREE. Search and download functionalities are using the official Maven repository.

ciris.syntax.scala Maven / Gradle / Ivy

There is a newer version: 0.12.1
Show newest version
package ciris

object syntax {
  implicit def eitherConfigErrorsSyntax[T](
    either: Either[ConfigErrors, T]
  ): EitherConfigErrorsSyntax[T] = {
    new EitherConfigErrorsSyntax(either)
  }

  final class EitherConfigErrorsSyntax[T](val either: Either[ConfigErrors, T]) extends AnyVal {

    /**
      * If the configuration was loaded successfully, returns the
      * configuration; otherwise, an exception is thrown with a
      * message detailing why the the loading failed.
      *
      * @return the configuration, or an exception if the
      *         configuration failed to load
      */
    def orThrow(): T =
      either.fold(
        errors => throw errors.toException,
        identity
      )
  }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy