UNPKG

@metamask/kernel-errors

Version:
1 lines 2.46 kB
{"version":3,"file":"VatAlreadyExistsError.mjs","sourceRoot":"","sources":["../../src/errors/VatAlreadyExistsError.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,8BAA8B;AAExE,OAAO,EAAE,SAAS,EAAE,yBAAwB;AAC5C,OAAO,EAAE,oBAAoB,EAAE,SAAS,EAAE,yBAAwB;AAGlE,MAAM,OAAO,qBAAsB,SAAQ,SAAS;IAClD,YAAY,KAAa,EAAE,OAA+B;QACxD,KAAK,CAAC,SAAS,CAAC,gBAAgB,EAAE,qBAAqB,EAAE;YACvD,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,MAAM,CAAC,cAAc,EAAE,IAAI,CAAC,MAAM,CAAC,CAAC;QACpC,OAAO,IAAI,qBAAqB,CAC9B,cAAc,CAAC,IAAI,CAAC,KAAK,EACzB,qBAAqB,CAAC,cAAc,CAAC,CACtC,CAAC;IACJ,CAAC;;AA7BD;;GAEG;AACW,4BAAM,GAAG,MAAM,CAAC;IAC5B,GAAG,oBAAoB;IACvB,IAAI,EAAE,OAAO,CAAC,SAAS,CAAC,gBAAgB,CAAC;IACzC,IAAI,EAAE,MAAM,CAAC;QACX,KAAK,EAAE,MAAM,EAAE;KAChB,CAAC;CACH,CAAC,CAAC;AAsBL,MAAM,CAAC,qBAAqB,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 VatAlreadyExistsError extends BaseError {\n constructor(vatId: string, options?: ErrorOptionsWithStack) {\n super(ErrorCode.VatAlreadyExists, 'Vat already exists.', {\n ...options,\n data: { vatId },\n });\n harden(this);\n }\n\n /**\n * A superstruct struct for validating marshaled {@link VatAlreadyExistsError} instances.\n */\n public static struct = object({\n ...marshaledErrorSchema,\n code: literal(ErrorCode.VatAlreadyExists),\n data: object({\n vatId: string(),\n }),\n });\n\n /**\n * Unmarshals a {@link MarshaledError} into a {@link VatAlreadyExistsError}.\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 ): VatAlreadyExistsError {\n assert(marshaledError, this.struct);\n return new VatAlreadyExistsError(\n marshaledError.data.vatId,\n unmarshalErrorOptions(marshaledError),\n );\n }\n}\nharden(VatAlreadyExistsError);\n"]}