

import makeError from "make-error";
import inspect from "object-inspect";

//#region src/error/BaseError.ts
/**
* @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