e) case class ConnctionError(cause: Throwable) extends DbException("Connection Error", cause) case class TimeoutError(cause: Throwable) extends DbException("Timeout Error", cause) case class TimeoutError(cause: Throwable) extends DbException("Duplicated Entry Error", cause) @Singleton class ExecuteImpl { def execute(): Future[SchemeModel] = { // It is possible the execute method raise some exceptions of DbCtxError. ctx.execute().map(Right.apply).rescue { case e: DbCtxCancelConnection => Left(ConnctionError(e)) case e: DbCtxTimeout => Left(TimeoutError(e)) case e: DbCtxDuplicatedEntry => Left(TimeoutError(e)) } } } ⶰ⡲欽搀椚ח㘗ד邌植׃זְ ྑ͘ͳ͍ͱߟ͍͑ͯΔॻ͖ํ
} @Singleton class ExecuteApiController @Inject()(executeImpl: ExecuteImpl) { // It is possible the execute method raise some exceptions of DbCtxError. def run(): Future[Unit] = executeImpl.execute().map(_ => ()) } @Singleton class Endpoint @Inject()(controller: ExecuteApiController) { override val executeApi(): Future[Unit] = { controller.run().rescue { case e: DbCtxError => Future.exception(e) } } } ྑ͍ͱߟ͍͑ͯΔॻ͖ํ