From 490b2cfed329abca227b14d9eeb273833c328238 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Viktor=20L=C3=B6vgren?= Date: Fri, 10 Nov 2017 15:49:44 +0000 Subject: [PATCH] Fix ConfigException#toString --- .../main/scala/ciris/ConfigException.scala | 23 +++---------------- 1 file changed, 3 insertions(+), 20 deletions(-) diff --git a/modules/core/shared/src/main/scala/ciris/ConfigException.scala b/modules/core/shared/src/main/scala/ciris/ConfigException.scala index fcc875b5..fe6270a7 100644 --- a/modules/core/shared/src/main/scala/ciris/ConfigException.scala +++ b/modules/core/shared/src/main/scala/ciris/ConfigException.scala @@ -3,32 +3,22 @@ package ciris /** * A `Throwable` representation of [[ConfigErrors]]. Useful in cases * where it's desirable to have failed configuration loading halt - * program execution - typically during application startup.
- *
- * There's a quick way to convert [[ConfigErrors]] to an exception. - * {{{ - * scala> ConfigErrors(ConfigError("error1")).toException - * res0: ConfigException = ConfigException(ConfigError(error1)) - * }}} + * program execution - typically during application startup. * * @param errors the underlying [[ConfigErrors]] of the exception */ final class ConfigException private (val errors: ConfigErrors) extends Throwable({ - val errorCount = - if (errors.size == 1) "error" - else s"[${errors.size}] errors" - val errorMessages = errors.toVector .map(error => s" - ${error.message}.") .mkString("\n", "\n", "\n") - s"configuration loading failed with the following $errorCount.\n$errorMessages" + s"configuration loading failed with the following errors.\n$errorMessages" }) { override def toString: String = - s"ConfigException(${errors.toVector.mkString(", ")})" + s"ciris.ConfigException: $getMessage" } object ConfigException { @@ -38,13 +28,6 @@ object ConfigException { * * @param errors the [[ConfigErrors]] from which to create the exception * @return a new [[ConfigException]] - * @example {{{ - * scala> ConfigException(ConfigError("error1") append ConfigError("error2")) - * res0: ConfigException = ConfigException(ConfigError(error1), ConfigError(error2)) - * - * scala> (ConfigError("error1") append ConfigError("error2")).toException - * res1: ConfigException = ConfigException(ConfigError(error1), ConfigError(error2)) - * }}} */ def apply(errors: ConfigErrors): ConfigException = new ConfigException(errors)