@credo-ts/core
Version:
<p align="center"> <br /> <img alt="Credo Logo" src="https://github.com/openwallet-foundation/credo-ts/blob/c7886cb8377ceb8ee4efe8d264211e561a75072d/images/credo-logo.png" height="250px" /> </p> <h1 align="center"><b>Credo - Core</b></h1
1 lines • 2.51 kB
Source Map (JSON)
{"version":3,"file":"BaseError.mjs","names":[],"sources":["../../src/error/BaseError.ts"],"sourcesContent":["/**\n * Copyright 2015 Blake Embrey\n * \n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n * \n * http://www.apache.org/licenses/LICENSE-2.0\n * \n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n *\n *\n/\n\n/**\n * Original code is from project <https://github.com/blakeembrey/make-error-cause>.\n *\n * Changes to the original code:\n * - Use inspect from `object-inspect` insted of Node.js `util` module.\n * - Change `inspect()` method signature\n */\n\nimport makeError from 'make-error'\nimport inspect from 'object-inspect'\n\n/**\n * @internal\n */\nexport const SEPARATOR_TEXT = '\\n\\nThe following exception was the direct cause of the above exception:\\n\\n'\n\n/**\n * Create a new error instance of `cause` property support.\n */\nexport class BaseError extends makeError.BaseError {\n protected constructor(\n message?: string,\n public cause?: Error\n ) {\n super(message)\n\n Object.defineProperty(this, 'cause', {\n value: cause,\n writable: false,\n enumerable: false,\n configurable: false,\n })\n }\n\n public inspect() {\n return fullStack(this)\n }\n}\n\n/**\n * Capture the full stack trace of any error instance.\n */\nexport function fullStack(error: Error | BaseError) {\n const chain: Error[] = []\n let cause: Error | undefined = error\n\n while (cause) {\n chain.push(cause)\n cause = (cause as BaseError).cause\n }\n\n return chain.map((err) => inspect(err, { customInspect: false })).join(SEPARATOR_TEXT)\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAgCA,MAAa,iBAAiB;;;;AAK9B,IAAa,YAAb,cAA+B,UAAU,UAAU;CACjD,YACE,SACA,OACA;EACA,MAAM,OAAO;EAFN,KAAA,QAAA;EAIP,OAAO,eAAe,MAAM,SAAS;GACnC,OAAO;GACP,UAAU;GACV,YAAY;GACZ,cAAc;EAChB,CAAC;CACH;CAEA,UAAiB;EACf,OAAO,UAAU,IAAI;CACvB;AACF;;;;AAKA,SAAgB,UAAU,OAA0B;CAClD,MAAM,QAAiB,CAAC;CACxB,IAAI,QAA2B;CAE/B,OAAO,OAAO;EACZ,MAAM,KAAK,KAAK;EAChB,QAAS,MAAoB;CAC/B;CAEA,OAAO,MAAM,KAAK,QAAQ,QAAQ,KAAK,EAAE,eAAe,MAAM,CAAC,CAAC,CAAC,CAAC,KAAK,cAAc;AACvF"}