aboutsummaryrefslogtreecommitdiff
path: root/core
diff options
context:
space:
mode:
authoradamw <adam@warski.org>2017-12-21 09:30:51 +0100
committeradamw <adam@warski.org>2017-12-21 09:30:51 +0100
commitd4e065dc3c8b80db24a96c83ddcca10b7aedc684 (patch)
tree1886f36e637acc961997e0b645411effa50cd6cd /core
parent2b1ed89d7468234c738f9f9789be23030bc6bdbc (diff)
downloadsttp-d4e065dc3c8b80db24a96c83ddcca10b7aedc684.tar.gz
sttp-d4e065dc3c8b80db24a96c83ddcca10b7aedc684.tar.bz2
sttp-d4e065dc3c8b80db24a96c83ddcca10b7aedc684.zip
Better not found message if no handlers match in the stub backend
Diffstat (limited to 'core')
-rw-r--r--core/src/main/scala/com/softwaremill/sttp/testing/SttpBackendStub.scala12
1 files changed, 7 insertions, 5 deletions
diff --git a/core/src/main/scala/com/softwaremill/sttp/testing/SttpBackendStub.scala b/core/src/main/scala/com/softwaremill/sttp/testing/SttpBackendStub.scala
index fed2acc..1d5b3c6 100644
--- a/core/src/main/scala/com/softwaremill/sttp/testing/SttpBackendStub.scala
+++ b/core/src/main/scala/com/softwaremill/sttp/testing/SttpBackendStub.scala
@@ -2,8 +2,8 @@ package com.softwaremill.sttp.testing
import java.io.{File, InputStream}
-import com.softwaremill.sttp.testing.SttpBackendStub._
import com.softwaremill.sttp._
+import com.softwaremill.sttp.testing.SttpBackendStub._
import scala.concurrent.Future
import scala.language.higherKinds
@@ -69,7 +69,12 @@ class SttpBackendStub[R[_], S] private (
wrapResponse(tryAdjustResponseType(request.response, response))
case Success(None) =>
fallback match {
- case None => wrapResponse(DefaultResponse)
+ case None =>
+ wrapResponse(
+ Response[Nothing](Left("Not Found: " + request.uri),
+ 404,
+ Nil,
+ Nil))
case Some(fb) => fb.send(request)
}
case Failure(e) => rm.error(e)
@@ -153,9 +158,6 @@ object SttpBackendStub {
PartialFunction.empty,
Some(fallback))
- private val DefaultResponse =
- Response[Nothing](Left("Not Found"), 404, Nil, Nil)
-
private[sttp] def tryAdjustResponseType[T, U](ra: ResponseAs[T, _],
r: Response[U]): Response[_] = {
r.body match {