diff --git a/Utils.js b/Utils.js index 26567cf..548ca5a 100644 --- a/Utils.js +++ b/Utils.js @@ -235,6 +235,23 @@ Ext.define('Proxmox.Utils', { utilities: { } }, + getResponseErrorMessage: (err) => { + if (!err.statusText) { + return gettext('Connection error'); + } + 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 += `
${key}: ${value}`; + } + } catch (e) { /* TODO? */ } + } + return msg; + }, + monStoreErrors: function(me, store, clearMaskBeforeLoad) { if (clearMaskBeforeLoad) { me.mon(store, 'beforeload', function(s, operation, eOpts) { @@ -258,15 +275,8 @@ Ext.define('Proxmox.Utils', { utilities: { return; } - var msg; - /*jslint nomen: true */ - var operation = request._operation; - var error = operation.getError(); - if (error.statusText) { - msg = error.statusText + ' (' + error.status + ')'; - } else { - msg = gettext('Connection error'); - } + let error = request._operation.getError(); + let msg = Proxmox.Utils.getResponseErrorMessage(error); Proxmox.Utils.setErrorMask(me, msg); }); }, diff --git a/css/ext6-pmx.css b/css/ext6-pmx.css index 7ee536d..83804d9 100644 --- a/css/ext6-pmx.css +++ b/css/ext6-pmx.css @@ -5,3 +5,7 @@ .pmx-hint { background-color: LightYellow; } + +.x-mask-msg-text { + text-align: center; +}