Skip to content

Commit

Permalink
chore: [SIW-1505] Export status attestation errors (#123)
Browse files Browse the repository at this point in the history
  • Loading branch information
LazyAfternoons authored Aug 27, 2024
1 parent fea8f1d commit dd546c3
Show file tree
Hide file tree
Showing 3 changed files with 41 additions and 33 deletions.
7 changes: 5 additions & 2 deletions src/credential/status/02-status-attestation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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<EvaluateIssuerTrust>["issuerConf"],
Expand Down
31 changes: 0 additions & 31 deletions src/credential/status/errors.ts

This file was deleted.

36 changes: 36 additions & 0 deletions src/utils/errors.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
}

0 comments on commit dd546c3

Please sign in to comment.