@metamask/kernel-errors
Version:
1 lines • 2.46 kB
Source Map (JSON)
{"version":3,"file":"SubclusterNotFoundError.cjs","sourceRoot":"","sources":["../../src/errors/SubclusterNotFoundError.ts"],"names":[],"mappings":";;;AAAA,uDAAwE;AAExE,mDAA4C;AAC5C,mDAAkE;AAGlE,MAAa,uBAAwB,SAAQ,wBAAS;IACpD,YAAY,YAAoB,EAAE,OAA+B;QAC/D,KAAK,CAAC,wBAAS,CAAC,kBAAkB,EAAE,4BAA4B,EAAE;YAChE,GAAG,OAAO;YACV,IAAI,EAAE,EAAE,YAAY,EAAE;SACvB,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,uBAAuB,CAChC,cAAc,CAAC,IAAI,CAAC,YAAY,EAChC,qBAAqB,CAAC,cAAc,CAAC,CACtC,CAAC;IACJ,CAAC;;AAtCH,0DAuCC;AA9BC;;GAEG;AACW,8BAAM,GAAG,IAAA,oBAAM,EAAC;IAC5B,GAAG,mCAAoB;IACvB,IAAI,EAAE,IAAA,qBAAO,EAAC,wBAAS,CAAC,kBAAkB,CAAC;IAC3C,IAAI,EAAE,IAAA,oBAAM,EAAC;QACX,YAAY,EAAE,IAAA,oBAAM,GAAE;KACvB,CAAC;CACH,CAAC,CAAC;AAsBL,MAAM,CAAC,uBAAuB,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 SubclusterNotFoundError extends BaseError {\n constructor(subclusterId: string, options?: ErrorOptionsWithStack) {\n super(ErrorCode.SubclusterNotFound, 'Subcluster does not exist.', {\n ...options,\n data: { subclusterId },\n });\n harden(this);\n }\n\n /**\n * A superstruct struct for validating marshaled {@link SubclusterNotFoundError} instances.\n */\n public static struct = object({\n ...marshaledErrorSchema,\n code: literal(ErrorCode.SubclusterNotFound),\n data: object({\n subclusterId: string(),\n }),\n });\n\n /**\n * Unmarshals a {@link MarshaledError} into a {@link SubclusterNotFoundError}.\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 ): SubclusterNotFoundError {\n assert(marshaledError, this.struct);\n return new SubclusterNotFoundError(\n marshaledError.data.subclusterId,\n unmarshalErrorOptions(marshaledError),\n );\n }\n}\nharden(SubclusterNotFoundError);\n"]}