
urldsl.errors.SimplePathMatchingError.scala Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of url-dsl_2.12 Show documentation
Show all versions of url-dsl_2.12 Show documentation
A tiny library for parsing and creating urls in a type-safe way
The newest version!
package urldsl.errors
import urldsl.vocabulary.Segment
sealed trait SimplePathMatchingError
object SimplePathMatchingError {
final case class EndOfSegmentRequired(remainingSegments: Seq[Segment]) extends SimplePathMatchingError
final case class WrongValue(expected: String, received: String) extends SimplePathMatchingError
case object MissingSegment extends SimplePathMatchingError
final case class SimpleError(reason: String) extends SimplePathMatchingError
case object AlwaysFalse extends SimplePathMatchingError
implicit lazy val pathMatchingError: PathMatchingError[SimplePathMatchingError] =
new PathMatchingError[SimplePathMatchingError] {
def malformed(str: => String): SimplePathMatchingError = SimpleError(str)
def endOfSegmentRequired(remainingSegments: => List[Segment]): SimplePathMatchingError =
EndOfSegmentRequired(remainingSegments)
def wrongValue(expected: => String, actual: => String): SimplePathMatchingError = WrongValue(expected, actual)
def missingSegment: SimplePathMatchingError = MissingSegment
def unit: SimplePathMatchingError = AlwaysFalse
}
implicit lazy val errorFromThrowable: ErrorFromThrowable[SimplePathMatchingError] = (throwable: Throwable) =>
SimpleError(throwable.getMessage)
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy