BookmarkStatus.Active, messageId = command.messageId, userAccountId = command.userAccountId, createdAt = now ) val result = for { message <- messageRepository.findById(command.messageId).recoverWith { case e: AggregateNotFoundException => Future.failed(new MessageNotFoundException(e)) } thread <- threadRepository.findById(message.breachEncapsulationOfThreadId).recoverWith { case e: AggregateNotFoundException => Future.failed(new ThreadNotFoundException(e)) } _ <- Future { if (!thread.hasMember(command.userAccountId)) throw new AddBookmarkForbiddenException("You are not a m } _ <- bookmarkRepository.store(bookmark) } yield { AddBookmarkSuccess(bookmarkId) } サマーインターンシップ2019 で学生とDDD なScala 開発に取り組んだ Scala 秋祭り 40 / 50