UNPKG

handlecustomerror

Version:

Custom Error Node Module

43 lines (29 loc) 1.22 kB
var errormsg = ""; errormsg += "<h1>Page Not Found</h1>"; errormsg += "<p>"; errormsg += "We're sorry, we can't find the page you were looking for. If you entered a web address please check it was correct."; errormsg += "</p><p>"; errormsg += "You can also return to the site you came from, or for more information about Elanco, visit <a href='https://www.elanco.com'> Elanco.com</a>."; errormsg += "</p>"; var customerrmsg = ""; customerrmsg += "<h1>SOMETHING WENT WRONG. <br/> PLEASE TRY AGAIN AFTER SOME TIME</h1>"; function pagenotfound() { return function redirects(request, response, next) { const err = new Error('Page Not Found'); err.status = 404; response.render("error", { message : errormsg, status : err.status }); }; }; /*function errrouter() { console.log("In middle ware block"); return function routerredirect(request, response){ console.log("In Error block"); response.render("error", { message : errormsg}); } };*/ function customerrormsg(request, response) { console.log("In Error block"); response.render("error", { message : customerrmsg}); } module.exports.pagenotfound = pagenotfound; module.exports.customerrormsg = customerrormsg;