"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.onRequestError = exports.isHttpException = void 0;
const common_1 = require("@nestjs/common");
const isRequestAborted = (request) => request.destroyed === true && request.complete === false;
const isHttpException = (error) => error instanceof common_1.HttpException;
exports.isHttpException = isHttpException;
const onRequestError = (req, error, logger) => {
    if ((0, exports.isHttpException)(error)) {
        const status = error.getStatus();
        const response = error.getResponse();
        logger.debug(`HttpException(${status}): ${JSON.stringify(response)}`);
        return;
    }
    if (isRequestAborted(req)) {
        logger.debug(`Client aborted request: ${error}`);
        return;
    }
    if (error instanceof Error) {
        logger.error(`Unknown error: ${error}`, error?.stack);
        return;
    }
};
exports.onRequestError = onRequestError;
//# sourceMappingURL=logger.js.map