import { captureException } from '@sentry/node';
import { ErrorHandler } from '../../../utils/ErrorHandler/ErrorHandler.js';
import logger from '../../../utils/logger.js';

class ViewReportController {
    layoutPath;
    services;
    constructor(layoutPath, services) {
        this.layoutPath = layoutPath;
        this.services = services;
    }
    errorHandler = async (error, req, res, _next) => {
        logger.error(`Error: ${JSON.stringify(req.body)}`);
        const formattedErr = new ErrorHandler(error || {}).formatError();
        captureException(error);
        res.render(`dpr/routes/journeys/view-report/error`, {
            layoutPath: this.layoutPath,
            ...(req.body && { ...req.body }),
            ...req.params,
            error: formattedErr,
            params: req.params,
        });
    };
}

export { ViewReportController, ViewReportController as default };
//# sourceMappingURL=controller.js.map
