kopia lustrzana https://github.com/c9/core
Merge pull request +9480 from c9/fix/dont-send-error-stacktraces
[trivial] Don't send error stacktracespull/199/head
commit
240b0904ab
|
@ -63,6 +63,8 @@ var statusCodes = {
|
||||||
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;
|
||||||
var showStackTrace = false;
|
var showStackTrace = false;
|
||||||
|
@ -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,
|
||||||
|
@ -120,6 +122,13 @@ function plugin(options, imports, register) {
|
||||||
};
|
};
|
||||||
|
|
||||||
for (var prop in err) error[prop] = err[prop];
|
for (var prop in err) error[prop] = err[prop];
|
||||||
|
try {
|
||||||
|
JSON.stringify(error);
|
||||||
|
} catch (e) {
|
||||||
|
console.error("Cannot send error as JSON: ", error);
|
||||||
|
error.message = NICE_USER_ERROR_MSG;
|
||||||
|
error.scope = null;
|
||||||
|
}
|
||||||
res.json({ error: error }, null, statusCode);
|
res.json({ error: error }, null, statusCode);
|
||||||
// plain text
|
// plain text
|
||||||
} else {
|
} else {
|
||||||
|
|
Ładowanie…
Reference in New Issue