export class ErrorWithLevel extends Error {
    logLevel;
    constructor(msg, logLevel = 'error', options) {
        super(msg, options);
        this.logLevel = logLevel;
    }
}
export function getLogLevel(error) {
    return error instanceof ErrorWithLevel ? error.logLevel : 'error';
}
export class ErrorForClient extends ErrorWithLevel {
    errorBody;
    constructor(errorBody, logLevel = 'warn', // 'warn' by default since these are generally not server issues
    options) {
        super(JSON.stringify(errorBody), logLevel, options);
        this.errorBody = errorBody;
    }
}
export function findErrorForClient(error) {
    if (error instanceof ErrorForClient) {
        return error;
    }
    if (error instanceof Error && error.cause) {
        return findErrorForClient(error.cause);
    }
    return undefined;
}
//# sourceMappingURL=error-for-client.js.map