diff options
author | Jakob Odersky <jakob@driver.xyz> | 2018-09-12 15:56:41 -0700 |
---|---|---|
committer | Jakob Odersky <jakob@odersky.com> | 2018-10-09 16:19:39 -0700 |
commit | 7a793ffa068fda8f2146f84fa785328d928dba03 (patch) | |
tree | d489b0b9ebf30ca61e2b6ef1c9906b704bc1fa1e /src/main/scala/xyz/driver/core/rest | |
parent | 2cef01adfe3ebd3a0fa1e0bbbba7f6388198ba10 (diff) | |
download | driver-core-7a793ffa068fda8f2146f84fa785328d928dba03.tar.gz driver-core-7a793ffa068fda8f2146f84fa785328d928dba03.tar.bz2 driver-core-7a793ffa068fda8f2146f84fa785328d928dba03.zip |
Move core types into core-types project
Note that xyz.driver.core.FutureExtensions was moved to
xyz.driver.core.rest as it (only) contained logic that dealt with
service exceptions, something that belongs into core-rest and must not
be depended upon by core-types.
This is a breaking change.
Diffstat (limited to 'src/main/scala/xyz/driver/core/rest')
-rw-r--r-- | src/main/scala/xyz/driver/core/rest/package.scala | 12 |
1 files changed, 11 insertions, 1 deletions
diff --git a/src/main/scala/xyz/driver/core/rest/package.scala b/src/main/scala/xyz/driver/core/rest/package.scala index 3be8f02..34a4a9d 100644 --- a/src/main/scala/xyz/driver/core/rest/package.scala +++ b/src/main/scala/xyz/driver/core/rest/package.scala @@ -15,10 +15,11 @@ import scalaz.Scalaz.{intInstance, stringInstance} import scalaz.syntax.equal._ import scalaz.{Functor, OptionT} import xyz.driver.core.rest.auth.AuthProvider +import xyz.driver.core.rest.errors.ExternalServiceException import xyz.driver.core.rest.headers.Traceparent import xyz.driver.tracing.TracingDirectives -import scala.concurrent.Future +import scala.concurrent.{ExecutionContext, Future} import scala.util.Try trait Service @@ -72,6 +73,15 @@ object ListResponse { } object `package` { + + implicit class FutureExtensions[T](future: Future[T]) { + def passThroughExternalServiceException(implicit executionContext: ExecutionContext): Future[T] = + future.transform(identity, { + case ExternalServiceException(_, _, Some(e)) => e + case t: Throwable => t + }) + } + implicit class OptionTRestAdditions[T](optionT: OptionT[Future, T]) { def responseOrNotFound(successCode: StatusCodes.Success = StatusCodes.OK)( implicit F: Functor[Future], |