From 25079dbdcddfbdf7b00402efe70f9f28a7aaf416 Mon Sep 17 00:00:00 2001 From: FabioPinheiro Date: Wed, 26 Jun 2024 11:01:18 +0100 Subject: [PATCH] Fixes after Review Signed-off-by: FabioPinheiro --- .../server/jobs/PresentBackgroundJobs.scala | 5 ++--- .../model/error/DIDSecretStorageError.scala | 4 ++-- .../identus/mercury/model/error/package.scala | 19 +------------------ 3 files changed, 5 insertions(+), 23 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 54fbad2e1e..b89cd14d2a 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 @@ -17,7 +17,6 @@ import org.hyperledger.identus.castor.core.model.error.DIDResolutionError as Cas import org.hyperledger.identus.castor.core.service.DIDService import org.hyperledger.identus.mercury.* import org.hyperledger.identus.mercury.model.* -import org.hyperledger.identus.mercury.model.error.TransportError import org.hyperledger.identus.mercury.protocol.presentproof.* import org.hyperledger.identus.mercury.protocol.reportproblem.v2.{ProblemCode, ReportProblem} import org.hyperledger.identus.pollux.core.model.* @@ -84,7 +83,7 @@ object PresentBackgroundJobs extends BackgroundJobsHelper { aux(record) .tapError({ (error: PresentationError | DIDSecretStorageError | BackgroundJobError | CredentialServiceError | - CastorDIDResolutionError | GetManagedDIDError | TransportError | Failure) => + CastorDIDResolutionError | GetManagedDIDError | Failure) => ZIO.logErrorCause( s"Present Proof - Error processing record: ${record.id}", Cause.fail(error) @@ -999,7 +998,7 @@ object PresentBackgroundJobs extends BackgroundJobsHelper { presentation: Presentation ): ZIO[ PresentationService & DIDNonSecretStorage & MESSAGING_RESOURCES, - PresentationError | DIDSecretStorageError | TransportError, + PresentationError | DIDSecretStorageError, Unit ] = { for { diff --git a/cloud-agent/service/wallet-api/src/main/scala/org/hyperledger/identus/agent/walletapi/model/error/DIDSecretStorageError.scala b/cloud-agent/service/wallet-api/src/main/scala/org/hyperledger/identus/agent/walletapi/model/error/DIDSecretStorageError.scala index fcc26e4b77..85a305541e 100644 --- a/cloud-agent/service/wallet-api/src/main/scala/org/hyperledger/identus/agent/walletapi/model/error/DIDSecretStorageError.scala +++ b/cloud-agent/service/wallet-api/src/main/scala/org/hyperledger/identus/agent/walletapi/model/error/DIDSecretStorageError.scala @@ -13,12 +13,12 @@ sealed trait DIDSecretStorageError( object DIDSecretStorageError { case class KeyNotFoundError(didId: DidId, keyId: String) extends DIDSecretStorageError( - StatusCode.InternalServerError, + StatusCode.NotFound, s"The not found: keyId='$keyId', didId='$didId'" ) case class WalletNotFoundError(didId: DidId) extends DIDSecretStorageError( - StatusCode.InternalServerError, + StatusCode.NotFound, s"The DID not Found in Wallet: didId='$didId'" ) } diff --git a/mercury/models/src/main/scala/org/hyperledger/identus/mercury/model/error/package.scala b/mercury/models/src/main/scala/org/hyperledger/identus/mercury/model/error/package.scala index 9a03550fc3..4ea83a1357 100644 --- a/mercury/models/src/main/scala/org/hyperledger/identus/mercury/model/error/package.scala +++ b/mercury/models/src/main/scala/org/hyperledger/identus/mercury/model/error/package.scala @@ -2,30 +2,13 @@ package org.hyperledger.identus.mercury.model import org.hyperledger.identus.shared.models._ -import java.io.IOException - package object error { - type MercuryException = MercuryError | IOException - type MercuryThrowable = MercuryError | IOException | Throwable // REMOVE Throwable - - def mercuryErrorAsThrowable(error: MercuryThrowable): java.lang.Throwable = error match - case ex: MercuryError => ex.toUnmanagedFailureException - case ex: IOException => ex - case ex: Throwable => ex - sealed trait MercuryError extends Failure { override val namespace: String = "MercuryError" } - trait TransportError extends MercuryError - - sealed case class SendMessageError(cause: Throwable, mData: Option[String] = None) - extends RuntimeException( - s"Error when sending message: ${cause.getMessage};${mData.map(e => s" DATA:'$e'").getOrElse("")}", - cause - ) - with TransportError { + sealed case class SendMessageError(cause: Throwable, mData: Option[String] = None) extends MercuryError { override val statusCode = StatusCode.BadRequest override val userFacingMessage = s"Error when sending message: ${cause.getMessage};${mData.map(e => s" DATA:'$e'").getOrElse("")}. "