web: improve error display when only {'detail'} is returned
Signed-off-by: Jens Langhammer <jens.langhammer@beryju.org>
This commit is contained in:
parent
7fea20375f
commit
92ce5f0931
|
@ -61,4 +61,4 @@ export const DEFAULT_CONFIG = new Configuration({
|
|||
],
|
||||
});
|
||||
|
||||
console.debug(`authentik: version ${VERSION}`);
|
||||
console.debug(`authentik(early): version ${VERSION}`);
|
||||
|
|
|
@ -224,9 +224,15 @@ export class Form<T> extends LitElement {
|
|||
throw ex;
|
||||
})
|
||||
.catch((ex: Error) => {
|
||||
let msg = ex.toString();
|
||||
// Only change the message when we have `detail`.
|
||||
// Everything else is handled in the form.
|
||||
if (ex instanceof APIError && "detail" in ex.response) {
|
||||
msg = ex.response.detail;
|
||||
}
|
||||
// error is local or not from rest_framework
|
||||
showMessage({
|
||||
message: ex.toString(),
|
||||
message: msg,
|
||||
level: MessageLevel.error,
|
||||
});
|
||||
// rethrow the error so the form doesn't close
|
||||
|
|
Reference in New Issue