-
Notifications
You must be signed in to change notification settings - Fork 22
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
5398a75
commit bd79a9e
Showing
14 changed files
with
124 additions
and
29 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
35 changes: 30 additions & 5 deletions
35
.../server/src/main/scala/org/hyperledger/identus/agent/server/jobs/BackgroundJobError.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,15 +1,40 @@ | ||
package org.hyperledger.identus.agent.server.jobs | ||
|
||
import org.hyperledger.identus.mercury.HttpResponse | ||
import org.hyperledger.identus.shared.models._ | ||
|
||
sealed trait BackgroundJobError | ||
sealed trait BackgroundJobError( | ||
override val statusCode: org.hyperledger.identus.shared.models.StatusCode, | ||
override val userFacingMessage: String | ||
) extends Failure { | ||
override val namespace: String = "BackgroundJobError" | ||
} | ||
|
||
object BackgroundJobError { | ||
final case class InvalidState(cause: String) extends BackgroundJobError | ||
|
||
final case class ErrorSendingMessage(cause: String) extends BackgroundJobError | ||
case object NotImplemented extends BackgroundJobError | ||
final case class ErrorResponseReceivedFromPeerAgent(response: HttpResponse) extends BackgroundJobError { | ||
final case class InvalidState(cause: String) | ||
extends BackgroundJobError( | ||
statusCode = StatusCode.FixmeStatusCode, | ||
userFacingMessage = s"Invalid State: cause='$cause'" | ||
) | ||
|
||
final case class ErrorSendingMessage(cause: String) | ||
extends BackgroundJobError( | ||
statusCode = StatusCode.FixmeStatusCode, | ||
userFacingMessage = s"ErrorSendingMessage" | ||
) | ||
|
||
case object NotImplemented | ||
extends BackgroundJobError( | ||
statusCode = StatusCode.FixmeStatusCode, | ||
userFacingMessage = s"NotImplemented" | ||
) | ||
final case class ErrorResponseReceivedFromPeerAgent(response: HttpResponse) | ||
extends BackgroundJobError( | ||
statusCode = StatusCode.FixmeStatusCode, | ||
userFacingMessage = s"DIDComm sending error: [${response.status}] - ${response.bodyAsString}" | ||
) { | ||
|
||
override def toString: String = s"DIDComm sending error: [${response.status}] - ${response.bodyAsString}" | ||
} | ||
} |
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
20 changes: 17 additions & 3 deletions
20
...ain/scala/org/hyperledger/identus/agent/walletapi/model/error/DIDSecretStorageError.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,10 +1,24 @@ | ||
package org.hyperledger.identus.agent.walletapi.model.error | ||
|
||
import org.hyperledger.identus.mercury.model.DidId | ||
import org.hyperledger.identus.shared.models._ | ||
|
||
sealed trait DIDSecretStorageError extends Throwable | ||
sealed trait DIDSecretStorageError( | ||
override val statusCode: StatusCode, | ||
override val userFacingMessage: String | ||
) extends Failure { | ||
override val namespace: String = "DIDSecretStorageError" | ||
} | ||
|
||
object DIDSecretStorageError { | ||
case class KeyNotFoundError(didId: DidId, keyId: String) extends DIDSecretStorageError | ||
case class WalletNotFoundError(didId: DidId) extends DIDSecretStorageError | ||
case class KeyNotFoundError(didId: DidId, keyId: String) | ||
extends DIDSecretStorageError( | ||
StatusCode.FixmeStatusCode, | ||
s"The not found: keyId='$keyId', didId='$didId'" | ||
) | ||
case class WalletNotFoundError(didId: DidId) | ||
extends DIDSecretStorageError( | ||
StatusCode.FixmeStatusCode, | ||
s"The DID not Found in Wallet: didId='$didId'" | ||
) | ||
} |
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
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
31 changes: 29 additions & 2 deletions
31
mercury/models/src/main/scala/org/hyperledger/identus/mercury/model/error/package.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,11 +1,38 @@ | ||
package org.hyperledger.identus.mercury.model | ||
|
||
import org.hyperledger.identus.shared.models._ | ||
|
||
import java.io.IOException | ||
|
||
package object error { | ||
|
||
sealed trait MercuryError | ||
type MercuryException = MercuryError | IOException | ||
type MercuryThrowable = MercuryError | IOException | Throwable // REMOVE Throwable | ||
|
||
def mercuryErrorAsThrowable(error: MercuryThrowable): java.lang.Throwable = error match | ||
// case ex: MercuryError => | ||
// ex match | ||
// case te: TransportError => new RuntimeException(te) | ||
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 TransportError | ||
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 { | ||
override val statusCode = org.hyperledger.identus.shared.models.StatusCode.FixmeStatusCode | ||
override val userFacingMessage = | ||
s"Error when sending message: ${cause.getMessage};${mData.map(e => s" DATA:'$e'").getOrElse("")}. " | ||
+ cause.getMessage | ||
} | ||
|
||
} |
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