web: fix error handling in forms for non-server errors

Signed-off-by: Jens Langhammer <jens.langhammer@beryju.org>
This commit is contained in:
Jens Langhammer 2021-03-27 23:39:28 +01:00
parent 2e6a264f98
commit 926636c331
1 changed files with 4 additions and 1 deletions

View File

@ -59,8 +59,11 @@ export class Form<T> extends LitElement {
return ex.json(); return ex.json();
} }
return ex; return ex;
}).then((errorMessage: ErrorResponse) => { }).then((errorMessage: ErrorResponse | Error) => {
if (!errorMessage) return errorMessage; if (!errorMessage) return errorMessage;
if (errorMessage instanceof Error) {
throw errorMessage;
}
const elements: PaperInputElement[] = ironForm._getSubmittableElements(); const elements: PaperInputElement[] = ironForm._getSubmittableElements();
elements.forEach((element) => { elements.forEach((element) => {
const elementName = element.name; const elementName = element.name;