@metamask/kernel-errors
Version:
1 lines • 2.35 kB
Source Map (JSON)
{"version":3,"file":"VatNotFoundError.cjs","sourceRoot":"","sources":["../../src/errors/VatNotFoundError.ts"],"names":[],"mappings":";;;AAAA,uDAAwE;AAExE,mDAA4C;AAC5C,mDAAkE;AAGlE,MAAa,gBAAiB,SAAQ,wBAAS;IAC7C,YAAY,KAAa,EAAE,OAA+B;QACxD,KAAK,CAAC,wBAAS,CAAC,WAAW,EAAE,qBAAqB,EAAE;YAClD,GAAG,OAAO;YACV,IAAI,EAAE,EAAE,KAAK,EAAE;SAChB,CAAC,CAAC;QACH,MAAM,CAAC,IAAI,CAAC,CAAC;IACf,CAAC;IAaD;;;;;;OAMG;IACI,MAAM,CAAC,SAAS,CACrB,cAAkC,EAClC,qBAE0B;QAE1B,IAAA,oBAAM,EAAC,cAAc,EAAE,IAAI,CAAC,MAAM,CAAC,CAAC;QACpC,OAAO,IAAI,gBAAgB,CACzB,cAAc,CAAC,IAAI,CAAC,KAAK,EACzB,qBAAqB,CAAC,cAAc,CAAC,CACtC,CAAC;IACJ,CAAC;;AAtCH,4CAuCC;AA9BC;;GAEG;AACW,uBAAM,GAAG,IAAA,oBAAM,EAAC;IAC5B,GAAG,mCAAoB;IACvB,IAAI,EAAE,IAAA,qBAAO,EAAC,wBAAS,CAAC,WAAW,CAAC;IACpC,IAAI,EAAE,IAAA,oBAAM,EAAC;QACX,KAAK,EAAE,IAAA,oBAAM,GAAE;KAChB,CAAC;CACH,CAAC,CAAC;AAsBL,MAAM,CAAC,gBAAgB,CAAC,CAAC","sourcesContent":["import { assert, literal, object, string } from '@metamask/superstruct';\n\nimport { BaseError } from '../BaseError.ts';\nimport { marshaledErrorSchema, ErrorCode } from '../constants.ts';\nimport type { ErrorOptionsWithStack, MarshaledOcapError } from '../types.ts';\n\nexport class VatNotFoundError extends BaseError {\n constructor(vatId: string, options?: ErrorOptionsWithStack) {\n super(ErrorCode.VatNotFound, 'Vat does not exist.', {\n ...options,\n data: { vatId },\n });\n harden(this);\n }\n\n /**\n * A superstruct struct for validating marshaled {@link VatNotFoundError} instances.\n */\n public static struct = object({\n ...marshaledErrorSchema,\n code: literal(ErrorCode.VatNotFound),\n data: object({\n vatId: string(),\n }),\n });\n\n /**\n * Unmarshals a {@link MarshaledError} into a {@link VatNotFoundError}.\n *\n * @param marshaledError - The marshaled error to unmarshal.\n * @param unmarshalErrorOptions - The function to unmarshal the error options.\n * @returns The unmarshaled error.\n */\n public static unmarshal(\n marshaledError: MarshaledOcapError,\n unmarshalErrorOptions: (\n marshaledError: MarshaledOcapError,\n ) => ErrorOptionsWithStack,\n ): VatNotFoundError {\n assert(marshaledError, this.struct);\n return new VatNotFoundError(\n marshaledError.data.vatId,\n unmarshalErrorOptions(marshaledError),\n );\n }\n}\nharden(VatNotFoundError);\n"]}