{
  "version": 3,
  "sources": ["../src/errors/base.ts"],
  "sourcesContent": [
    "/**\n * Derive a stable machine-readable code from an error's `name` field:\n * `HttpRequestError` becomes `HTTP_REQUEST_ERROR`. `name` is a string\n * literal each class sets, so the code survives a bundler that mangles\n * class names. Branch on `code` instead of parsing `message`, which is\n * free to change.\n */\nfunction codeFromName(name: string): string {\n\treturn name\n\t\t.replace(/([a-z0-9])([A-Z])/g, \"$1_$2\")\n\t\t.replace(/([A-Z]+)([A-Z][a-z])/g, \"$1_$2\")\n\t\t.toUpperCase();\n}\n\nexport class BaseError extends Error {\n\toverride name = \"StacksError\";\n\t#code?: string;\n\tshortMessage: string;\n\tdetails?: string;\n\n\tconstructor(\n\t\tshortMessage: string,\n\t\toptions?: { cause?: Error; details?: string; code?: string },\n\t) {\n\t\tconst message = [\n\t\t\tshortMessage,\n\t\t\toptions?.details ? `\\n${options.details}` : \"\",\n\t\t].join(\"\");\n\n\t\tsuper(message, { cause: options?.cause });\n\t\tif (options?.code !== undefined) this.#code = options.code;\n\t\tthis.shortMessage = shortMessage;\n\t\tthis.details = options?.details;\n\t}\n\n\t/**\n\t * Stable identifier for programmatic handling; survives message\n\t * rewording and minification. An explicit `code` option wins, else it\n\t * is derived from `name` (`TimeoutError` gives `TIMEOUT_ERROR`).\n\t */\n\tget code(): string {\n\t\treturn this.#code ?? codeFromName(this.name);\n\t}\n\n\tset code(value: string) {\n\t\tthis.#code = value;\n\t}\n\n\ttoJSON(): {\n\t\tname: string;\n\t\tcode: string;\n\t\tmessage: string;\n\t\tshortMessage: string;\n\t\tdetails: string | undefined;\n\t\tcause: string | undefined;\n\t} {\n\t\treturn {\n\t\t\tname: this.name,\n\t\t\tcode: this.code,\n\t\t\tmessage: this.message,\n\t\t\tshortMessage: this.shortMessage,\n\t\t\tdetails: this.details,\n\t\t\tcause: this.cause instanceof Error ? this.cause.message : undefined,\n\t\t};\n\t}\n}\n"
  ],
  "mappings": ";AAOA,SAAS,YAAY,CAAC,MAAsB;AAAA,EAC3C,OAAO,KACL,QAAQ,sBAAsB,OAAO,EACrC,QAAQ,yBAAyB,OAAO,EACxC,YAAY;AAAA;AAAA;AAGR,MAAM,kBAAkB,MAAM;AAAA,EAC3B,OAAO;AAAA,EAChB;AAAA,EACA;AAAA,EACA;AAAA,EAEA,WAAW,CACV,cACA,SACC;AAAA,IACD,MAAM,UAAU;AAAA,MACf;AAAA,MACA,SAAS,UAAU;AAAA,EAAK,QAAQ,YAAY;AAAA,IAC7C,EAAE,KAAK,EAAE;AAAA,IAET,MAAM,SAAS,EAAE,OAAO,SAAS,MAAM,CAAC;AAAA,IACxC,IAAI,SAAS,SAAS;AAAA,MAAW,KAAK,QAAQ,QAAQ;AAAA,IACtD,KAAK,eAAe;AAAA,IACpB,KAAK,UAAU,SAAS;AAAA;AAAA,MAQrB,IAAI,GAAW;AAAA,IAClB,OAAO,KAAK,SAAS,aAAa,KAAK,IAAI;AAAA;AAAA,MAGxC,IAAI,CAAC,OAAe;AAAA,IACvB,KAAK,QAAQ;AAAA;AAAA,EAGd,MAAM,GAOJ;AAAA,IACD,OAAO;AAAA,MACN,MAAM,KAAK;AAAA,MACX,MAAM,KAAK;AAAA,MACX,SAAS,KAAK;AAAA,MACd,cAAc,KAAK;AAAA,MACnB,SAAS,KAAK;AAAA,MACd,OAAO,KAAK,iBAAiB,QAAQ,KAAK,MAAM,UAAU;AAAA,IAC3D;AAAA;AAEF;",
  "debugId": "74E75E1C13F951A764756E2164756E21",
  "names": []
}