{"size": 639, "ext": "js", "max_stars_repo_path": "app/utils/error.js", "max_stars_repo_name": "sinzii/frameworkless", "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "app/utils/error.js", "max_issues_repo_name": "sinzii/frameworkless", "max_issues_repo_issues_event_min_datetime": "2021-05-08T10:28:14.000Z", "max_issues_repo_issues_event_max_datetime": "2021-05-12T10:14:07.000Z", "max_forks_repo_path": "app/utils/error.js", "max_forks_repo_name": "sinzii/frameworkless", "max_forks_repo_forks_event_min_datetime": "2021-05-18T03:25:10.000Z", "max_forks_repo_forks_event_max_datetime": "2021-05-18T03:25:10.000Z"}
{"max_stars_count": null, "max_issues_count": 3, "max_forks_count": 1, "avg_line_length": 24.5769230769, "max_line_length": 86, "alphanum_fraction": 0.661971831}
const viewsEngine = require('../views_engine');

const sendErrorCode = async (res, statusCode = 500, message) => {
    message = message || 'There was a problem occurred while processing the request.';

    let errorPage;
    try {
        errorPage = await viewsEngine.getTemplate(`error_${statusCode}`);
    } catch (e) {
        errorPage = await viewsEngine.getTemplate(`error`);
    }

    res.send(errorPage({message, statusCode}), statusCode);
}


const send404Error = async (res, message = "Oops! There's nothing here!") => {
    await sendErrorCode(res, 404, message);
}

module.exports = {
    sendErrorCode,
    send404Error
}

