{"size": 480, "ext": "js", "max_stars_repo_path": "templates/basic/web/src/controllers/examples/error-handling.js", "max_stars_repo_name": "mannyvergel/oils-js", "max_stars_repo_stars_event_min_datetime": "2016-04-06T16:35:56.000Z", "max_stars_repo_stars_event_max_datetime": "2020-06-11T09:58:13.000Z", "max_issues_repo_path": "templates/basic/web/src/controllers/examples/error-handling.js", "max_issues_repo_name": "mannyvergel/oils-js", "max_issues_repo_issues_event_min_datetime": "2020-02-12T03:53:36.000Z", "max_issues_repo_issues_event_max_datetime": "2021-08-06T06:35:15.000Z", "max_forks_repo_path": "templates/basic/web/src/controllers/examples/error-handling.js", "max_forks_repo_name": "mannyvergel/oils-js", "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null}
{"max_stars_count": 2, "max_issues_count": 8, "max_forks_count": null, "avg_line_length": 20.0, "max_line_length": 59, "alphanum_fraction": 0.5895833333}
'use strict';

module.exports = {
  get: async function(req, res, next) {
    console.log('Accessing', req.url);

    let myPromise = new Promise(function(resolve, reject) {
      setTimeout(function() {
        throw new Error("Some error");
      }, 500);
    });

    await myPromise;
    
  },

  onError: function(req, res, err) {
    req.flash('error', err.message);

    res.render('examples/error-handling.html');
    //you can also redirect
    //res.redirect(...);
  }
}