diff --git a/src/credential/status/02-status-attestation.ts b/src/credential/status/02-status-attestation.ts index 0808d8eb..dceb1b98 100644 --- a/src/credential/status/02-status-attestation.ts +++ b/src/credential/status/02-status-attestation.ts @@ -7,8 +7,11 @@ import type { EvaluateIssuerTrust, ObtainCredential } from "../issuance"; import { SignJWT, type CryptoContext } from "@pagopa/io-react-native-jwt"; import uuid from "react-native-uuid"; import { StatusAttestationResponse } from "./types"; -import { UnexpectedStatusCodeError } from "../../utils/errors"; -import { StatusAttestationError, StatusAttestationInvalid } from "./errors"; +import { + StatusAttestationError, + StatusAttestationInvalid, + UnexpectedStatusCodeError, +} from "../../utils/errors"; export type StatusAttestation = ( issuerConf: Out["issuerConf"], diff --git a/src/credential/status/errors.ts b/src/credential/status/errors.ts deleted file mode 100644 index 71edd033..00000000 --- a/src/credential/status/errors.ts +++ /dev/null @@ -1,31 +0,0 @@ -import { IoWalletError, serializeAttrs } from "../../utils/errors"; - -export class StatusAttestationInvalid extends IoWalletError { - static get code(): "ERR_STATUS_ATTESTATION_INVALID" { - return "ERR_STATUS_ATTESTATION_INVALID"; - } - - code = "ERR_STATUS_ATTESTATION_INVALID"; - - reason: string; - - constructor(message: string, reason: string = "unspecified") { - super(serializeAttrs({ message, reason })); - this.reason = reason; - } -} - -export class StatusAttestationError extends IoWalletError { - static get code(): "ERR_STATUS_ATTESTATION_ERROR" { - return "ERR_STATUS_ATTESTATION_ERROR"; - } - - code = "ERR_STATUS_ATTESTATION_ERROR"; - - reason: string; - - constructor(message: string, reason: string = "unspecified") { - super(serializeAttrs({ message, reason })); - this.reason = reason; - } -} diff --git a/src/utils/errors.ts b/src/utils/errors.ts index 761202d6..e02c50ac 100644 --- a/src/utils/errors.ts +++ b/src/utils/errors.ts @@ -390,3 +390,39 @@ export class OperationAbortedError extends IoWalletError { this.operation = operation; } } + +/** + * Error subclass thrown when the status attestation for a credential is invalid. + */ +export class StatusAttestationInvalid extends IoWalletError { + static get code(): "ERR_STATUS_ATTESTATION_INVALID" { + return "ERR_STATUS_ATTESTATION_INVALID"; + } + + code = "ERR_STATUS_ATTESTATION_INVALID"; + + reason: string; + + constructor(message: string, reason: string = "unspecified") { + super(serializeAttrs({ message, reason })); + this.reason = reason; + } +} + +/** + * Error subclass thrown when an error occurs while obtaining a status attestation for a credential. + */ +export class StatusAttestationError extends IoWalletError { + static get code(): "ERR_STATUS_ATTESTATION_ERROR" { + return "ERR_STATUS_ATTESTATION_ERROR"; + } + + code = "ERR_STATUS_ATTESTATION_ERROR"; + + reason: string; + + constructor(message: string, reason: string = "unspecified") { + super(serializeAttrs({ message, reason })); + this.reason = reason; + } +}