When we can't stringify the error log it and tell the user, don't send them a stack trace

pull/199/head
Tim Robinson 2015-09-18 10:59:54 +00:00
rodzic b2f6598e34
commit 9db5aff1c9
1 zmienionych plików z 6 dodań i 0 usunięć

Wyświetl plik

@ -120,6 +120,12 @@ function plugin(options, imports, register) {
};
for (var prop in err) error[prop] = err[prop];
try {
JSON.stringify(error);
} catch (e) {
console.error("Cannot send error as JSON: ", error);
error = "Unspecified error";
}
res.json({ error: error }, null, statusCode);
// plain text
} else {