Have a nice error

pull/199/head
Tim Robinson 2015-09-18 12:14:46 +00:00
rodzic 0d8fbef5d6
commit 01746cac14
1 zmienionych plików z 4 dodań i 2 usunięć

Wyświetl plik

@ -62,6 +62,8 @@ var statusCodes = {
510: "Not Extended", 510: "Not Extended",
511: "Network Authentication Required" 511: "Network Authentication Required"
}; };
var NICE_USER_ERROR_MSG = "Something went wrong. Please retry in a few minutes and contact support if it continues to occur";
function plugin(options, imports, register) { function plugin(options, imports, register) {
var connect = imports.connect; var connect = imports.connect;
@ -104,7 +106,7 @@ function plugin(options, imports, register) {
res.setHeader('Content-Type', 'text/html; charset=utf-8'); res.setHeader('Content-Type', 'text/html; charset=utf-8');
res.render(path, { res.render(path, {
title: statusCodes[statusCode] || "Unspecified Error", title: statusCodes[statusCode] || NICE_USER_ERROR_MSG,
scope: options.scope || "", scope: options.scope || "",
showStackTrace: showStackTrace, showStackTrace: showStackTrace,
stack: stack, stack: stack,
@ -124,7 +126,7 @@ function plugin(options, imports, register) {
JSON.stringify(error); JSON.stringify(error);
} catch (e) { } catch (e) {
console.error("Cannot send error as JSON: ", error); console.error("Cannot send error as JSON: ", error);
error.message = "Unspecified error"; error.message = NICE_USER_ERROR_MSG;
error.scope = null; error.scope = null;
} }
res.json({ error: error }, null, statusCode); res.json({ error: error }, null, statusCode);