diff --git a/web/src/elements/forms/Form.ts b/web/src/elements/forms/Form.ts index d28dd5751..931978041 100644 --- a/web/src/elements/forms/Form.ts +++ b/web/src/elements/forms/Form.ts @@ -145,7 +145,10 @@ export class Form extends LitElement { }) ); return r; - }).catch((ex: Response) => { + }).catch((ex: Response | Error) => { + if (ex instanceof Error) { + throw ex; + } if (ex.status > 399 && ex.status < 500) { return ex.json().then((errorMessage: ValidationError) => { if (!errorMessage) return errorMessage; @@ -169,6 +172,14 @@ export class Form extends LitElement { }); } throw ex; + }).catch((ex: Error) => { + // error is local or not from rest_framework + showMessage({ + message: ex.toString(), + level: MessageLevel.error, + }); + // rethrow the error so the form doesn't close + throw ex; }); }