{"size": 772, "ext": "js", "max_stars_repo_path": "middlewares/error/custom.js", "max_stars_repo_name": "foxyjacob/agora", "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "middlewares/error/custom.js", "max_issues_repo_name": "foxyjacob/agora", "max_issues_repo_issues_event_min_datetime": "2017-09-13T09:04:09.000Z", "max_issues_repo_issues_event_max_datetime": "2017-09-13T23:32:20.000Z", "max_forks_repo_path": "middlewares/error/custom.js", "max_forks_repo_name": "foxyjacob/agora", "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null}
{"max_stars_count": null, "max_issues_count": 7, "max_forks_count": null, "avg_line_length": 27.5714285714, "max_line_length": 109, "alphanum_fraction": 0.5259067358}
"use strict";

/* Generic Error Handler
 * =====================
 * Handles custom errors based on the data passed to next. If no custom error
 * handler is defined, the error is delegated to the next error-handling
 * middleware.
 *
 * ========================================================================= */

var middleware = function(err, req, res, next) {
    var context;

    switch (err) {
        case "":
            // Define a custom error here
            break;
    }

    if (context) {
        res.render("error.html.njk", context); // If we set a context, we must have recognized the error
    } else {
        next(err);                         // Otherwise, we should delegate this error to the generic handler
    }
};

module.exports = middleware;
