mirror of
https://github.com/YunoHost/yunohost-admin.git
synced 2024-09-03 20:06:15 +02:00
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:
commit
a586e8d6b9
1 changed files with 12 additions and 3 deletions
|
@ -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
|
||||||
|
|
Loading…
Reference in a new issue