From a0f84354599dc1b49d95576af3a00bd07d8ceac6 Mon Sep 17 00:00:00 2001 From: mineme0110 Date: Mon, 18 Nov 2024 16:02:39 +0000 Subject: [PATCH] Improved the error reporting Signed-off-by: mineme0110 --- .../server/jobs/PresentBackgroundJobs.scala | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/cloud-agent/service/server/src/main/scala/org/hyperledger/identus/agent/server/jobs/PresentBackgroundJobs.scala b/cloud-agent/service/server/src/main/scala/org/hyperledger/identus/agent/server/jobs/PresentBackgroundJobs.scala index ea627e94a3..a6f2bfae67 100644 --- a/cloud-agent/service/server/src/main/scala/org/hyperledger/identus/agent/server/jobs/PresentBackgroundJobs.scala +++ b/cloud-agent/service/server/src/main/scala/org/hyperledger/identus/agent/server/jobs/PresentBackgroundJobs.scala @@ -948,7 +948,7 @@ object PresentBackgroundJobs extends BackgroundJobsHelper { object Verifier { - def handleRequestPending(id: DidCommID, record: RequestPresentation): ZIO[ + def handleRequestPending(id: DidCommID, requestPresentation: RequestPresentation): ZIO[ JwtDidResolver & COMMON_RESOURCES & MESSAGING_RESOURCES, Failure, Unit @@ -979,17 +979,20 @@ object PresentBackgroundJobs extends BackgroundJobsHelper { val verifierReqPendingToSentFlow = for { _ <- ZIO.log(s"PresentationRecord: RequestPending (Send Message)") - walletAccessContext <- buildWalletAccessContextLayer( - record.from.getOrElse(throw new RuntimeException("from is None is not possible")) - ) + walletAccessContext <- ZIO + .fromOption(requestPresentation.from) + .mapError(_ => RequestPresentationMissingField(id.value, "sender")) + .flatMap(buildWalletAccessContextLayer) + result <- for { didOps <- ZIO.service[DidOps] - didCommAgent <- buildDIDCommAgent( - record.from.getOrElse(throw new RuntimeException("from is None is not possible")) - ).provideSomeLayer(ZLayer.succeed(walletAccessContext)) + didCommAgent <- ZIO + .fromOption(requestPresentation.from) + .mapError(_ => RequestPresentationMissingField(id.value, "sender")) + .flatMap(buildDIDCommAgent(_).provideSomeLayer(ZLayer.succeed(walletAccessContext))) resp <- MessagingService - .send(record.makeMessage) + .send(requestPresentation.makeMessage) .provideSomeLayer(didCommAgent) @@ Metric .gauge("present_proof_flow_verifier_send_presentation_request_msg_ms_gauge")