UNPKG

@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

69 lines (64 loc) • 1.78 kB
import makeError from "make-error"; import inspect from "object-inspect"; //#region src/error/BaseError.ts /** * Copyright 2015 Blake Embrey * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * * / /** * Original code is from project <https://github.com/blakeembrey/make-error-cause>. * * Changes to the original code: * - Use inspect from `object-inspect` insted of Node.js `util` module. * - Change `inspect()` method signature */ /** * @internal */ const SEPARATOR_TEXT = "\n\nThe following exception was the direct cause of the above exception:\n\n"; /** * Create a new error instance of `cause` property support. */ var BaseError = class extends makeError.BaseError { constructor(message, cause) { super(message); this.cause = cause; Object.defineProperty(this, "cause", { value: cause, writable: false, enumerable: false, configurable: false }); } inspect() { return fullStack(this); } }; /** * Capture the full stack trace of any error instance. */ function fullStack(error) { const chain = []; let cause = error; while (cause) { chain.push(cause); cause = cause.cause; } return chain.map((err) => inspect(err, { customInspect: false })).join(SEPARATOR_TEXT); } //#endregion export { BaseError }; //# sourceMappingURL=BaseError.mjs.map