-
Notifications
You must be signed in to change notification settings - Fork 23
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(connect): ATL-6599 Use ZIO Failures and Defects effectively + RF…
…C-9457 in connect (#927) Signed-off-by: Benjamin Voiturier <[email protected]>
- Loading branch information
1 parent
9a38cc9
commit eb898e0
Showing
35 changed files
with
839 additions
and
693 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
58 changes: 48 additions & 10 deletions
58
...b/core/src/main/scala/io/iohk/atala/connect/core/model/error/ConnectionServiceError.scala
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,17 +1,55 @@ | ||
package io.iohk.atala.connect.core.model.error | ||
|
||
import io.iohk.atala.connect.core.model.ConnectionRecord.ProtocolState | ||
import io.iohk.atala.shared.models.{Failure, StatusCode} | ||
import zio.NonEmptyChunk | ||
|
||
import java.util.UUID | ||
|
||
sealed trait ConnectionServiceError | ||
sealed trait ConnectionServiceError( | ||
val statusCode: StatusCode, | ||
val userFacingMessage: String | ||
) extends Failure | ||
|
||
object ConnectionServiceError { | ||
final case class RepositoryError(cause: Throwable) extends ConnectionServiceError | ||
final case class RecordIdNotFound(recordId: UUID) extends ConnectionServiceError | ||
final case class ThreadIdNotFound(thid: String) extends ConnectionServiceError | ||
final case class InvitationParsingError(cause: Throwable) extends ConnectionServiceError | ||
final case class UnexpectedError(msg: String) extends ConnectionServiceError | ||
final case class InvalidFlowStateError(msg: String) extends ConnectionServiceError | ||
final case class InvitationAlreadyReceived(msg: String) extends ConnectionServiceError | ||
final case class InvitationExpired(msg: String) extends ConnectionServiceError | ||
|
||
final case class UserInputValidationError(errors: NonEmptyChunk[String]) | ||
extends ConnectionServiceError( | ||
StatusCode.BadRequest, | ||
s"The provided input failed validation: errors=${errors.mkString("[", "], [", "]")}" | ||
) | ||
final case class InvitationParsingError(cause: String) | ||
extends ConnectionServiceError( | ||
StatusCode.BadRequest, | ||
s"An error occurred while parsing the invitation content: cause=[$cause]" | ||
) | ||
final case class InvitationAlreadyReceived(invitationId: String) | ||
extends ConnectionServiceError( | ||
StatusCode.BadRequest, | ||
s"The provided invitation has already been used: invitationId=$invitationId" | ||
) | ||
final case class RecordIdNotFound(recordId: UUID) | ||
extends ConnectionServiceError( | ||
StatusCode.NotFound, | ||
s"There is no connection record matching the provided identifier: recordId=$recordId" | ||
) | ||
final case class ThreadIdNotFound(thid: String) | ||
extends ConnectionServiceError( | ||
StatusCode.NotFound, | ||
s"There is no connection record matching the provided identifier: thid=$thid" | ||
) | ||
final case class ThreadIdMissingInReceivedMessage(msgId: String) | ||
extends ConnectionServiceError( | ||
StatusCode.BadRequest, | ||
s"The received DIDComm message does not include a 'thid' field: messageId=$msgId" | ||
) | ||
final case class InvalidStateForOperation(state: ProtocolState) | ||
extends ConnectionServiceError( | ||
StatusCode.BadRequest, | ||
s"The operation is not allowed for the current connection record state: $state=$state" | ||
) | ||
final case class InvitationExpired(invitationId: String) | ||
extends ConnectionServiceError( | ||
StatusCode.BadRequest, | ||
s"The provided invitation has expired: invitationId=$invitationId" | ||
) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.