-
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.
fix: present error handling Part 2 (#1177)
Signed-off-by: Bassam Riman <[email protected]>
- Loading branch information
1 parent
dffad1d
commit 9ac6e52
Showing
16 changed files
with
219 additions
and
136 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
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
3 changes: 1 addition & 2 deletions
3
...ce/CredentialDefinitionServiceError.scala → ...or/CredentialDefinitionServiceError.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
2 changes: 1 addition & 1 deletion
2
...ervice/CredentialSchemaServiceError.scala → .../error/CredentialSchemaServiceError.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
171 changes: 154 additions & 17 deletions
171
...re/src/main/scala/org/hyperledger/identus/pollux/core/model/error/PresentationError.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,24 +1,161 @@ | ||
package org.hyperledger.identus.pollux.core.model.error | ||
|
||
import org.hyperledger.identus.pollux.core.model.schema.validator.JsonSchemaError | ||
import org.hyperledger.identus.pollux.core.model.DidCommID | ||
import org.hyperledger.identus.pollux.core.service.URIDereferencerError | ||
import org.hyperledger.identus.shared.models.{Failure, StatusCode} | ||
|
||
sealed trait PresentationError | ||
sealed trait PresentationError( | ||
val statusCode: StatusCode, | ||
val userFacingMessage: String | ||
) extends Failure { | ||
override val namespace = "Presentation" | ||
} | ||
|
||
object PresentationError { | ||
final case class RecordIdNotFound(recordId: DidCommID) extends PresentationError | ||
final case class ThreadIdNotFound(thid: DidCommID) extends PresentationError | ||
final case class InvalidFlowStateError(msg: String) extends PresentationError | ||
final case class UnexpectedError(msg: String) extends PresentationError | ||
final case class IssuedCredentialNotFoundError(cause: String) extends PresentationError | ||
final case class NotMatchingPresentationCredentialFormat(cause: Throwable) extends PresentationError | ||
final case class PresentationDecodingError(cause: String) extends PresentationError | ||
final case class HolderBindingError(msg: String) extends PresentationError | ||
object MissingCredential extends PresentationError | ||
object MissingCredentialFormat extends PresentationError | ||
final case class UnsupportedCredentialFormat(vcFormat: String) extends PresentationError | ||
final case class InvalidAnoncredPresentationRequest(error: String) extends PresentationError | ||
final case class InvalidAnoncredPresentation(error: String) extends PresentationError | ||
final case class MissingAnoncredPresentationRequest(error: String) extends PresentationError | ||
final case class AnoncredPresentationCreationError(cause: Throwable) extends PresentationError | ||
final case class AnoncredPresentationVerificationError(cause: Throwable) extends PresentationError | ||
|
||
// TODO: Remove once PresentationJob is cleaned | ||
final case class UnexpectedError(error: String) | ||
extends PresentationError( | ||
StatusCode.InternalServerError, | ||
error | ||
) | ||
|
||
final case class RecordIdNotFound(recordId: DidCommID) | ||
extends PresentationError( | ||
StatusCode.NotFound, | ||
s"Record Id not found: $recordId" | ||
) | ||
|
||
final case class ThreadIdNotFound(thid: DidCommID) | ||
extends PresentationError( | ||
StatusCode.NotFound, | ||
s"Thread Id not found: $thid" | ||
) | ||
|
||
final case class NoThreadIdFoundInRecord(presentationId: String) | ||
extends PresentationError( | ||
StatusCode.InternalServerError, | ||
s"Presentation record has missing ThreadId for record: $presentationId" | ||
) | ||
|
||
final case class InvalidFlowStateError(msg: String) | ||
extends PresentationError( | ||
StatusCode.BadRequest, | ||
msg | ||
) | ||
|
||
final case class RequestPresentationHasMultipleAttachment(presentationId: String) | ||
extends PresentationError( | ||
StatusCode.BadRequest, | ||
s"Request Presentation with multi attachments: $presentationId" | ||
) | ||
|
||
final case class IssuedCredentialNotFoundError(cause: String) | ||
extends PresentationError( | ||
StatusCode.InternalServerError, | ||
"Issued credential not found" | ||
) | ||
|
||
final case class InvalidSchemaURIError(schemaUri: String, error: Throwable) | ||
extends PresentationError( | ||
StatusCode.BadRequest, | ||
s"Invalid Schema Uri: $schemaUri, Error: ${error.getMessage}" | ||
) | ||
|
||
final case class InvalidCredentialDefinitionURIError(credentialDefinitionUri: String, error: Throwable) | ||
extends PresentationError( | ||
StatusCode.BadRequest, | ||
s"Invalid Credential Definition Uri: $credentialDefinitionUri, Error: ${error.getMessage}" | ||
) | ||
|
||
final case class SchemaURIDereferencingError(error: URIDereferencerError) | ||
extends PresentationError( | ||
error.statusCode, | ||
error.userFacingMessage | ||
) | ||
|
||
final case class CredentialDefinitionURIDereferencingError(error: URIDereferencerError) | ||
extends PresentationError( | ||
error.statusCode, | ||
error.userFacingMessage | ||
) | ||
|
||
final case class PresentationDecodingError(cause: String) | ||
extends PresentationError( | ||
StatusCode.InternalServerError, | ||
s"Presentation decoding error: $cause" | ||
) | ||
|
||
final case class HolderBindingError(msg: String) | ||
extends PresentationError( | ||
StatusCode.InternalServerError, | ||
s"Holder binding error: $msg" | ||
) | ||
|
||
object MissingCredential | ||
extends PresentationError( | ||
StatusCode.BadRequest, | ||
s"The Credential is missing from attachments" | ||
) | ||
|
||
object MissingCredentialFormat | ||
extends PresentationError( | ||
StatusCode.BadRequest, | ||
s"The Credential format is missing from the credential in attachment" | ||
) | ||
|
||
final case class UnsupportedCredentialFormat(vcFormat: String) | ||
extends PresentationError( | ||
StatusCode.BadRequest, | ||
s"The Credential format '$vcFormat' is not Unsupported" | ||
) | ||
|
||
final case class InvalidAnoncredPresentationRequest(error: String) | ||
extends PresentationError( | ||
StatusCode.InternalServerError, | ||
error | ||
) | ||
|
||
final case class InvalidAnoncredPresentation(error: String) | ||
extends PresentationError( | ||
StatusCode.InternalServerError, | ||
error | ||
) | ||
|
||
final case class MissingAnoncredPresentationRequest(error: String) | ||
extends PresentationError( | ||
StatusCode.InternalServerError, | ||
error | ||
) | ||
|
||
final case class NotMatchingPresentationCredentialFormat(cause: Throwable) | ||
extends PresentationError( | ||
StatusCode.BadRequest, | ||
s"Presentation and Credential Format Not Matching: ${cause.toString}" | ||
) | ||
|
||
final case class AnoncredPresentationCreationError(cause: Throwable) | ||
extends PresentationError( | ||
StatusCode.InternalServerError, | ||
cause.toString | ||
) | ||
|
||
final case class AnoncredCredentialProofParsingError(cause: String) | ||
extends PresentationError( | ||
StatusCode.BadRequest, | ||
cause | ||
) | ||
|
||
final case class AnoncredPresentationParsingError(cause: JsonSchemaError) | ||
extends PresentationError( | ||
StatusCode.BadRequest, | ||
cause.error | ||
) | ||
|
||
final case class AnoncredPresentationVerificationError(cause: Throwable) | ||
extends PresentationError( | ||
StatusCode.BadRequest, | ||
cause.toString | ||
) | ||
} |
1 change: 1 addition & 0 deletions
1
.../main/scala/org/hyperledger/identus/pollux/core/service/CredentialDefinitionService.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
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
1 change: 1 addition & 0 deletions
1
.../src/main/scala/org/hyperledger/identus/pollux/core/service/CredentialSchemaService.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
8 changes: 7 additions & 1 deletion
8
.../main/scala/org/hyperledger/identus/pollux/core/service/CredentialSchemaServiceImpl.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
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.