// SPDX-License-Identifier: Apache-2.0
export class SoloError extends Error {
    message;
    cause;
    meta;
    statusCode;
    /**
     * Create a custom error object
     *
     * error metadata will include the `cause`
     *
     * @param message error message
     * @param cause source error (if any)
     * @param meta additional metadata (if any)
     */
    constructor(message, cause = {}, meta = {}) {
        super(message);
        this.message = message;
        this.cause = cause;
        this.meta = meta;
        this.name = this.constructor.name;
        this.statusCode = cause?.statusCode;
        // eslint-disable-next-line unicorn/no-useless-error-capture-stack-trace
        Error.captureStackTrace(this, this.constructor);
        if (cause) {
            this.cause = cause;
            if (cause instanceof Error) {
                this.stack += `\nCaused by: ${this.cause.stack}`;
            }
        }
    }
}
//# sourceMappingURL=solo-error.js.map