mirror of
https://git.proxmox.com/git/proxmox-widget-toolkit
synced 2025-05-29 06:46:34 +00:00
monStoreErrors: refactor out and render param exception errors
adapt the .x-mask-msg-text class to center the text, as else this looks not to nice.. Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
This commit is contained in:
parent
c6cf52f197
commit
dca21e597e
28
Utils.js
28
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 += `<br>${key}: ${value}`;
|
||||||
|
}
|
||||||
|
} catch (e) { /* TODO? */ }
|
||||||
|
}
|
||||||
|
return msg;
|
||||||
|
},
|
||||||
|
|
||||||
monStoreErrors: function(me, store, clearMaskBeforeLoad) {
|
monStoreErrors: function(me, store, clearMaskBeforeLoad) {
|
||||||
if (clearMaskBeforeLoad) {
|
if (clearMaskBeforeLoad) {
|
||||||
me.mon(store, 'beforeload', function(s, operation, eOpts) {
|
me.mon(store, 'beforeload', function(s, operation, eOpts) {
|
||||||
@ -258,15 +275,8 @@ Ext.define('Proxmox.Utils', { utilities: {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
var msg;
|
let error = request._operation.getError();
|
||||||
/*jslint nomen: true */
|
let msg = Proxmox.Utils.getResponseErrorMessage(error);
|
||||||
var operation = request._operation;
|
|
||||||
var error = operation.getError();
|
|
||||||
if (error.statusText) {
|
|
||||||
msg = error.statusText + ' (' + error.status + ')';
|
|
||||||
} else {
|
|
||||||
msg = gettext('Connection error');
|
|
||||||
}
|
|
||||||
Proxmox.Utils.setErrorMask(me, msg);
|
Proxmox.Utils.setErrorMask(me, msg);
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
@ -5,3 +5,7 @@
|
|||||||
.pmx-hint {
|
.pmx-hint {
|
||||||
background-color: LightYellow;
|
background-color: LightYellow;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.x-mask-msg-text {
|
||||||
|
text-align: center;
|
||||||
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user