Skip to content

Commit

Permalink
Rename failToDisambiguate to noOptionFound
Browse files Browse the repository at this point in the history
  • Loading branch information
jcazevedo committed May 3, 2019
1 parent 2bdaad1 commit 8da8f67
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 6 deletions.
Expand Up @@ -5,7 +5,6 @@ import pureconfig._
import pureconfig.error._
import pureconfig.generic.error.{ NoValidCoproductChoiceFound, UnexpectedValueForFieldCoproductHint }
import pureconfig.syntax._
import shapeless.CNil

/**
* A trait that can be implemented to disambiguate between the different options of a coproduct or sealed family.
Expand Down Expand Up @@ -56,8 +55,8 @@ trait CoproductHint[T] {
* @param cur a `ConfigCursor` at the sealed family option
* @return a failed `ConfigReader` result scoped into the context of a `ConfigCursor`.
*/
def failToDisambiguate(cur: ConfigCursor): ConfigReader.Result[CNil] =
cur.failed(NoValidCoproductChoiceFound(cur.value))
def noOptionFound(cur: ConfigCursor): ConfigReaderFailures =
ConfigReaderFailures(cur.failureFor(NoValidCoproductChoiceFound(cur.value)))
}

/**
Expand Down Expand Up @@ -105,8 +104,11 @@ class FieldCoproductHint[T](key: String) extends CoproductHint[T] {

def tryNextOnFail(name: String) = false

override def failToDisambiguate(cur: ConfigCursor): ConfigReader.Result[CNil] =
cur.fluent.at(key).cursor.right.flatMap(cur => cur.failed(UnexpectedValueForFieldCoproductHint(cur.value)))
override def noOptionFound(cur: ConfigCursor): ConfigReaderFailures =
cur.fluent.at(key).cursor.fold(
identity,
cur => ConfigReaderFailures(cur.failureFor(UnexpectedValueForFieldCoproductHint(cur.value))))
}
}

/**
Expand Down
Expand Up @@ -72,7 +72,7 @@ object MapShapedReader {
coproductHint: CoproductHint[Wrapped]): MapShapedReader[Wrapped, CNil] =
new MapShapedReader[Wrapped, CNil] {
override def from(cur: ConfigCursor): ConfigReader.Result[CNil] =
coproductHint.failToDisambiguate(cur)
Left(coproductHint.noOptionFound(cur))
}

final implicit def cConsReader[Wrapped, Name <: Symbol, V, T <: Coproduct](
Expand Down

0 comments on commit 8da8f67

Please sign in to comment.