diff --git a/cloud-agent/service/server/src/main/scala/org/hyperledger/identus/didcomm/controller/DIDCommControllerError.scala b/cloud-agent/service/server/src/main/scala/org/hyperledger/identus/didcomm/controller/DIDCommControllerError.scala index 5a27032b75..4c7208fda0 100644 --- a/cloud-agent/service/server/src/main/scala/org/hyperledger/identus/didcomm/controller/DIDCommControllerError.scala +++ b/cloud-agent/service/server/src/main/scala/org/hyperledger/identus/didcomm/controller/DIDCommControllerError.scala @@ -1,6 +1,6 @@ package org.hyperledger.identus.didcomm.controller -import org.hyperledger.identus.mercury.model.DidId +import org.hyperledger.identus.mercury.model.{DidId, PIURI} import org.hyperledger.identus.shared.models.{Failure, KeyId, StatusCode} sealed trait DIDCommControllerError extends Failure { @@ -39,4 +39,10 @@ object DIDCommControllerError { override def userFacingMessage: String = s"The Peer DID does not contain the required key: DID=${did.value}, keyId=${keyId.value}" } + + final case class UnsupportedPIURI(piuri: PIURI) extends DIDCommControllerError { + override def statusCode: StatusCode = StatusCode.UnprocessableContent + override def userFacingMessage: String = + s"The Protocol Identifier URI (URI) found in the DIDComm message is not supported: PIURI=$piuri" + } } diff --git a/cloud-agent/service/server/src/main/scala/org/hyperledger/identus/didcomm/controller/DIDCommControllerImpl.scala b/cloud-agent/service/server/src/main/scala/org/hyperledger/identus/didcomm/controller/DIDCommControllerImpl.scala index b910ace0f4..b13d522e03 100644 --- a/cloud-agent/service/server/src/main/scala/org/hyperledger/identus/didcomm/controller/DIDCommControllerImpl.scala +++ b/cloud-agent/service/server/src/main/scala/org/hyperledger/identus/didcomm/controller/DIDCommControllerImpl.scala @@ -184,8 +184,8 @@ class DIDCommControllerImpl( /* * Unknown Message */ - private val handleUnknownMessage: PartialFunction[Message, UIO[String]] = { case _ => - ZIO.succeed("Unknown Message Type") + private val handleUnknownMessage: PartialFunction[Message, IO[UnsupportedPIURI, String]] = { case msg => + ZIO.fail(UnsupportedPIURI(msg.piuri)) } }