Merge pull request #220 from YunoHost/do-not-fail-miserably-on-error-500-bad-json

Do not fail miserably if we don't have proper json during error 500
This commit is contained in:
Alexandre Aubin 2018-12-18 16:14:38 +01:00 committed by GitHub
commit a586e8d6b9
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -122,9 +122,18 @@
} }
// 500 // 500
else if (xhr.status == 500) { else if (xhr.status == 500) {
error_log = JSON.parse(xhr.responseText); try {
error_log.route = error_log.route.join(' ') + '\n'; error_log = JSON.parse(xhr.responseText);
error_log.arguments = JSON.stringify(error_log.arguments); error_log.route = error_log.route.join(' ') + '\n';
error_log.arguments = JSON.stringify(error_log.arguments);
}
catch (e)
{
error_log = {};
error_log.route = "Failed to parse route";
error_log.arguments = "Failed to parse arguments";
error_log.traceback = xhr.responseText;
}
c.flash('fail', y18n.t('internal_exception', [error_log.route, error_log.arguments, error_log.traceback])); c.flash('fail', y18n.t('internal_exception', [error_log.route, error_log.arguments, error_log.traceback]));
} }
// 502 Bad gateway means API is down // 502 Bad gateway means API is down