diff options
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.scala | 40 |
1 files changed, 9 insertions, 31 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 index 94f9734..7aa70bf 100644 --- a/src/main/scala/xyz/driver/core/rest/errors/serviceException.scala +++ b/src/main/scala/xyz/driver/core/rest/errors/serviceException.scala @@ -1,41 +1,19 @@ package xyz.driver.core.rest.errors -import akka.http.scaladsl.model.{StatusCode, StatusCodes} - abstract class ServiceException extends Exception { - def isPatientSensitive: Boolean = false - - def statusCode: StatusCode def message: String } -final case class InvalidInputException(override val message: String = "Invalid input", - override val isPatientSensitive: Boolean = false) - extends ServiceException { - override def statusCode: StatusCode = StatusCodes.BadRequest -} +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", - override val isPatientSensitive: Boolean = false) - extends ServiceException { - override def statusCode: StatusCode = StatusCodes.Forbidden -} +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", - override val isPatientSensitive: Boolean = false) - extends ServiceException { - override def statusCode: StatusCode = StatusCodes.NotFound -} +final case class ResourceNotFoundException(override val message: String = "Resource not found") + extends ServiceException -final case class ExternalServiceTimeoutException(override val message: String = - "Another service took too long to respond", - override val isPatientSensitive: Boolean = false) - extends ServiceException { - override def statusCode: StatusCode = StatusCodes.GatewayTimeout -} +final case class ExternalServiceTimeoutException( + override val message: String = "Another service took too long to respond") + extends ServiceException -final case class DatabaseException(override val message: String = "Database access error", - override val isPatientSensitive: Boolean = false) - extends ServiceException { - override def statusCode: StatusCode = StatusCodes.InternalServerError -} +final case class DatabaseException(override val message: String = "Database access error") extends ServiceException |