UNPKG

@metamask/kernel-errors

Version:
35 lines 1.3 kB
import { assert, literal, object, string } from "@metamask/superstruct"; import { BaseError } from "../BaseError.mjs"; import { marshaledErrorSchema, ErrorCode } from "../constants.mjs"; export class VatAlreadyExistsError extends BaseError { constructor(vatId, options) { super(ErrorCode.VatAlreadyExists, 'Vat already exists.', { ...options, data: { vatId }, }); harden(this); } /** * Unmarshals a {@link MarshaledError} into a {@link VatAlreadyExistsError}. * * @param marshaledError - The marshaled error to unmarshal. * @param unmarshalErrorOptions - The function to unmarshal the error options. * @returns The unmarshaled error. */ static unmarshal(marshaledError, unmarshalErrorOptions) { assert(marshaledError, this.struct); return new VatAlreadyExistsError(marshaledError.data.vatId, unmarshalErrorOptions(marshaledError)); } } /** * A superstruct struct for validating marshaled {@link VatAlreadyExistsError} instances. */ VatAlreadyExistsError.struct = object({ ...marshaledErrorSchema, code: literal(ErrorCode.VatAlreadyExists), data: object({ vatId: string(), }), }); harden(VatAlreadyExistsError); //# sourceMappingURL=VatAlreadyExistsError.mjs.map