

const require_rolldown_runtime = require('../_virtual/rolldown_runtime.js');
let make_error = require("make-error");
make_error = require_rolldown_runtime.__toESM(make_error);
let object_inspect = require("object-inspect");
object_inspect = require_rolldown_runtime.__toESM(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 make_error.default.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) => (0, object_inspect.default)(err, { customInspect: false })).join(SEPARATOR_TEXT);
}

//#endregion
exports.BaseError = BaseError;