web: improve error handing for fetch in AdminLoginChart

This commit is contained in:
Jens Langhammer
2021-03-03 10:06:44 +01:00
parent 28cd08bbba
commit 5218332bce
4 changed files with 19 additions and 15 deletions

View File

@ -1,3 +1,5 @@
import { gettext } from "django";
import { showMessage } from "../elements/messages/MessageContainer";
import { getCookie } from "../utils";
import { NotFoundError, RequestError } from "./Error";
@ -47,6 +49,13 @@ export class Client {
}
return r;
})
.catch((e) => {
showMessage({
level_tag: "error",
message: gettext(`Unexpected error while fetching: ${e.toString()}`),
});
return e;
})
.then((r) => r.json())
.then((r) => <T>r);
}