diff --git a/ui/src/components/DoorMapEditor.vue b/ui/src/components/DoorMapEditor.vue index 2dffa34..4186c64 100644 --- a/ui/src/components/DoorMapEditor.vue +++ b/ui/src/components/DoorMapEditor.vue @@ -76,7 +76,7 @@ export default class extends Vue { public doors: Door[] = []; private load_doors(): Promise { - return this.$advent22.api_get("/general/doors").then((data) => { + return this.$advent22.api_get("general/doors").then((data) => { this.doors.length = 0; for (const value of data) { @@ -96,18 +96,22 @@ export default class extends Vue { data.push(door.save()); } - return this.$advent22.api_put("/general/doors", data); + return this.$advent22.api_put("general/doors", data); } public mounted(): void { - this.load_doors().catch((reason) => alert(`Fehler: ${reason}`)); + this.load_doors().catch(([reason, endpoint]) => { + alert(`Fehler: ${reason} in ${endpoint}`); + }); } public on_download() { if (confirm("Aktuelle Änderungen verwerfen und Status vom Server laden?")) { this.load_doors() .then(() => alert("Erfolgeich!")) - .catch((reason) => alert(`Fehler: ${reason}`)); + .catch(([reason, endpoint]) => { + alert(`Fehler: ${reason} in ${endpoint}`); + }); } } @@ -121,7 +125,13 @@ export default class extends Vue { public on_upload() { if (confirm("Aktuelle Änderungen an den Server schicken?")) { this.save_doors() - .then(() => alert("Erfolgeich!")) + .then(() => { + this.load_doors() + .then(() => alert("Erfolgeich!")) + .catch(([reason, endpoint]) => + alert(`Fehler: ${reason} in ${endpoint}`), + ); + }) .catch((reason) => alert(`Fehler: ${reason}`)); } } diff --git a/ui/src/components/calendar/CalendarDoor.vue b/ui/src/components/calendar/CalendarDoor.vue index ac02604..cf4a803 100644 --- a/ui/src/components/calendar/CalendarDoor.vue +++ b/ui/src/components/calendar/CalendarDoor.vue @@ -30,12 +30,19 @@ export default class extends Vue { .catch(([reason]) => { let msg = "Unbekannter Fehler, bitte wiederholen!"; - if ( - reason instanceof AxiosError && - reason.response !== undefined && - reason.response.status === 401 - ) { - msg = "Netter Versuch :)"; + if (reason instanceof AxiosError) { + if (reason.code === "ECONNABORTED") { + // API unerreichbar + msg = "API antwortet nicht, bitte später wiederholen!"; + } else if (reason.response !== undefined) { + if (reason.response.status === 401) { + // 401 UNAUTHORIZED + msg = "Netter Versuch :)"; + } else if (reason.response.status === 422) { + // 422 UNPROCESSABLE ENTITY + msg = "Türchen ist kaputt, bitte Admin benachrichtigen!"; + } + } } this.$emit("doorFailure", msg); diff --git a/ui/src/plugins/advent22.ts b/ui/src/plugins/advent22.ts index 72db94a..9895655 100644 --- a/ui/src/plugins/advent22.ts +++ b/ui/src/plugins/advent22.ts @@ -78,7 +78,7 @@ export class Advent22 { if (typeof reader.result === "string") { resolve(reader.result); } else { - reject([endpoint, "failed data url"]); + reject(["failed data url", endpoint]); } }; })