Skip to content

Commit

Permalink
Merge a41f632 into 6229fd5
Browse files Browse the repository at this point in the history
  • Loading branch information
sebver committed May 20, 2020
2 parents 6229fd5 + a41f632 commit b6a2f50
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 8 deletions.
3 changes: 2 additions & 1 deletion modules/sttp/build.sbt
@@ -1,7 +1,8 @@
name := "pureconfig-sttp"

libraryDependencies ++= Seq(
"com.softwaremill.sttp" %% "core" % "1.7.2")
"com.softwaremill.sttp.model" %% "core" % "1.1.3"
)

developers := List(
Developer("bszwej", "Bartlomiej Szwej", "bszwej@gmail.com", url("https://github.com/bszwej")))
Expand Down
@@ -1,6 +1,8 @@
package pureconfig.module

import com.softwaremill.sttp.{ sttp => _, _ }
import _root_.sttp.model._
import _root_.sttp.model.Uri._

import pureconfig.ConfigReader
import pureconfig.error.CannotConvert

Expand All @@ -12,7 +14,7 @@ package object sttp {
ConfigReader.fromNonEmptyString { str =>
Try(uri"$str") match {
case Success(uri) => Right(uri)
case Failure(ex) => Left(CannotConvert(str, "com.softwaremill.sttp.Uri", ex.getMessage))
case Failure(ex) => Left(CannotConvert(str, "sttp.model.Uri", ex.getMessage))
}
}

Expand Down
@@ -1,6 +1,7 @@
package pureconfig.module.sttp

import com.softwaremill.sttp._
import sttp.model.Uri
import sttp.model.Uri._
import com.typesafe.config.ConfigFactory
import pureconfig.BaseSuite
import pureconfig.error.{ CannotConvert, ConfigReaderFailures, ConvertFailure }
Expand All @@ -20,14 +21,14 @@ class SttpSuite extends BaseSuite {
}

it should "handle error when reading uri" in {
val config = ConfigFactory.parseString("""{uri = "https!!://wrong.io"}""")
val config = ConfigFactory.parseString("""{uri = "sttp.readthedocs.io"}""")

val failure =
ConvertFailure(
reason = CannotConvert(
value = "https!!://wrong.io",
toType = "com.softwaremill.sttp.Uri",
because = "requirement failed: Scheme can only contain alphanumeric characters, +, - and ."),
value = "sttp.readthedocs.io",
toType = "sttp.model.Uri",
because = "missing scheme"),
location = None,
path = "uri")

Expand Down

0 comments on commit b6a2f50

Please sign in to comment.