<commit_before>"use strict";

/**
 * ContactMeController class.
 */
class ContactMeController {
    /**
     * ContactMeController constructor.
     *
     * @param {Mailer} mailer
     */
    constructor(mailer) {
        this._mailer = mailer;
        this.send = this.send.bind(this);
    }

    /**
     * Send contact me message.
     *
     * @param req
     * @param res
     * @param next
     */
    async send(req, res, next) {
        const from = `${req.body.name} <${req.body.email}>`;
        const to = process.env.APP_EMAIL;
        const subject = `${process.env.APP_NAME} - ${req.__("contact_me")}`;
        const text = req.body.message;

        try {
            await this._mailer.send({from, to, subject, text});
        } catch (err) {
            next(err);
        }

        req.flash("flashes", {type: "success", message: req.__("contact_me_form_success_alert")});
        res.redirect(req.generateUrl("/"));
    }
}

module.exports = ContactMeController;<commit_msg>Fixed contact me controller error handling flow issue<commit_after>"use strict";

/**
 * ContactMeController class.
 */
class ContactMeController {
    /**
     * ContactMeController constructor.
     *
     * @param {Mailer} mailer
     */
    constructor(mailer) {
        this._mailer = mailer;
        this.send = this.send.bind(this);
    }

    /**
     * Send contact me message.
     *
     * @param req
     * @param res
     * @param next
     */
    async send(req, res, next) {
        const from = `${req.body.name} <${req.body.email}>`;
        const to = process.env.APP_EMAIL;
        const subject = `${process.env.APP_NAME} - ${req.__("contact_me")}`;
        const text = req.body.message;

        try {
            await this._mailer.send({from, to, subject, text});
        } catch (err) {
            next(err);
            return;
        }

        req.flash("flashes", {type: "success", message: req.__("contact_me_form_success_alert")});
        res.redirect(req.generateUrl("/"));
    }
}

module.exports = ContactMeController;
{'fraction_non_alphanumeric': 0.15073170731707317, 'fraction_numerical': 0.0, 'mean_word_length': 2.1122913505311076, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5508470', 'n_tokens_mistral': 634, 'n_tokens_neox': 634, 'n_words': 129}