improve error extraction for monStoreErrors
by printing the whole error body when it cannot be parsed as JSON Signed-off-by: Dominik Csapak <d.csapak@proxmox.com>
This commit is contained in:
parent
187e9a6d3a
commit
9fcd1bdb42
15
Utils.js
15
Utils.js
@ -244,17 +244,22 @@ Ext.define('Proxmox.Utils', { utilities: {
|
||||
if (!err.statusText) {
|
||||
return gettext('Connection error');
|
||||
}
|
||||
let msg = `${err.statusText} (${err.status})`;
|
||||
let msg = [`${err.statusText} (${err.status})`];
|
||||
if (err.response && err.response.responseText) {
|
||||
let txt = err.response.responseText;
|
||||
try {
|
||||
let res = JSON.parse(txt)
|
||||
for (let [key, value] of Object.entries(res.errors)) {
|
||||
msg += `<br>${key}: ${value}`;
|
||||
if (res.errors && typeof res.errors === 'object') {
|
||||
for (let [key, value] of Object.entries(res.errors)) {
|
||||
msg.push(Ext.String.htmlEncode(`${key}: ${value}`));
|
||||
}
|
||||
}
|
||||
} catch (e) { /* TODO? */ }
|
||||
} catch (e) {
|
||||
// fallback to string
|
||||
msg.push(Ext.String.htmlEncode(txt));
|
||||
}
|
||||
}
|
||||
return msg;
|
||||
return msg.join('<br>');
|
||||
},
|
||||
|
||||
monStoreErrors: function(me, store, clearMaskBeforeLoad) {
|
||||
|
Loading…
Reference in New Issue
Block a user