UNPKG

@metamask/kernel-errors

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