UNPKG

@metamask/kernel-errors

Version:
35 lines 1.26 kB
import { assert, literal, object, string } from "@metamask/superstruct"; import { BaseError } from "../BaseError.mjs"; import { marshaledErrorSchema, ErrorCode } from "../constants.mjs"; export class VatNotFoundError extends BaseError { constructor(vatId, options) { super(ErrorCode.VatNotFound, 'Vat does not exist.', { ...options, data: { vatId }, }); harden(this); } /** * Unmarshals a {@link MarshaledError} into a {@link VatNotFoundError}. * * @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 VatNotFoundError(marshaledError.data.vatId, unmarshalErrorOptions(marshaledError)); } } /** * A superstruct struct for validating marshaled {@link VatNotFoundError} instances. */ VatNotFoundError.struct = object({ ...marshaledErrorSchema, code: literal(ErrorCode.VatNotFound), data: object({ vatId: string(), }), }); harden(VatNotFoundError); //# sourceMappingURL=VatNotFoundError.mjs.map