diff --git a/static/js/ui/vlm.js b/static/js/ui/vlm.js index fd819db..1cdad69 100644 --- a/static/js/ui/vlm.js +++ b/static/js/ui/vlm.js @@ -162,11 +162,17 @@ const VlmUI = { body: formData, }) .then(function(r) { + if (r.status === 413) { + throw new Error('Bild zu gross fuer Upload. Bitte kleineres Bild verwenden.'); + } if (r.status === 429) { throw new Error('Eine Analyse laeuft bereits. Bitte warten.'); } if (!r.ok) { - return r.json().then(function(d) { throw new Error(d.detail || 'Fehler ' + r.status); }); + return r.text().then(function(txt) { + try { var d = JSON.parse(txt); throw new Error(d.detail || 'Fehler ' + r.status); } + catch(e) { if (e.message && !e.message.startsWith('Unexpected')) throw e; throw new Error('Server-Fehler ' + r.status); } + }); } return r.json(); })