aboutsummaryrefslogtreecommitdiff
path: root/src/main/scala/xyz/driver/core/rest/errors/serviceException.scala
diff options
context:
space:
mode:
authorzachdriver <zach@driver.xyz>2017-11-01 10:23:25 -0700
committerGitHub <noreply@github.com>2017-11-01 10:23:25 -0700
commitd480ea203d836739534fd8d27005a1e0a168c30f (patch)
treea444fbafefccf232e68e72b3f592cd3e0bca3396 /src/main/scala/xyz/driver/core/rest/errors/serviceException.scala
parent0cb06d70bd91e1e6a4ab9d97851ef9db7aaedfd6 (diff)
parent595d199f5e41c8e48131cec98b23452bc7ed6ef1 (diff)
downloaddriver-core-1.5.2.tar.gz
driver-core-1.5.2.tar.bz2
driver-core-1.5.2.zip
Merge pull request #73 from drivergroup/zsmith/route-traitv1.6.0v1.5.2
Add DriverRoute trait and APIError types
Diffstat (limited to 'src/main/scala/xyz/driver/core/rest/errors/serviceException.scala')
-rw-r--r--src/main/scala/xyz/driver/core/rest/errors/serviceException.scala23
1 files changed, 23 insertions, 0 deletions
diff --git a/src/main/scala/xyz/driver/core/rest/errors/serviceException.scala b/src/main/scala/xyz/driver/core/rest/errors/serviceException.scala
new file mode 100644
index 0000000..e91a3c2
--- /dev/null
+++ b/src/main/scala/xyz/driver/core/rest/errors/serviceException.scala
@@ -0,0 +1,23 @@
+package xyz.driver.core.rest.errors
+
+sealed abstract class ServiceException extends Exception {
+ def message: String
+}
+
+final case class InvalidInputException(override val message: String = "Invalid input") extends ServiceException
+
+final case class InvalidActionException(override val message: String = "This action is not allowed")
+ extends ServiceException
+
+final case class ResourceNotFoundException(override val message: String = "Resource not found")
+ extends ServiceException
+
+final case class ExternalServiceException(serviceName: String, serviceMessage: String) extends ServiceException {
+ override def message = s"Error while calling '$serviceName': $serviceMessage"
+}
+
+final case class ExternalServiceTimeoutException(serviceName: String) extends ServiceException {
+ override def message = s"$serviceName took too long to respond"
+}
+
+final case class DatabaseException(override val message: String = "Database access error") extends ServiceException