add and use $advent22.alert_user_error

This commit is contained in:
Jörn-Michael Miehe 2023-11-02 00:41:42 +00:00
parent 8e4ea78873
commit dae862fc55
6 changed files with 10 additions and 6 deletions

View file

@ -64,7 +64,7 @@ export default class extends Vue {
this.subtitle = subtitle; this.subtitle = subtitle;
this.footer = footer; this.footer = footer;
}) })
.catch((error) => alert(this.$advent22.format_user_error(error))); .catch(this.$advent22.alert_user_error);
} }
} }
</script> </script>

View file

@ -44,7 +44,7 @@ export default class extends Vue {
this.store this.store
.login(creds) .login(creds)
.catch((error) => alert(this.$advent22.format_user_error(error))) .catch(this.$advent22.alert_user_error)
.finally(() => (this.is_busy = false)); .finally(() => (this.is_busy = false));
} }

View file

@ -64,7 +64,7 @@ export default class extends Vue {
this.$advent22 this.$advent22
.api_get<number | null>("user/next_door") .api_get<number | null>("user/next_door")
.then((next_door) => (this.next_door = next_door)) .then((next_door) => (this.next_door = next_door))
.catch((error) => alert(this.$advent22.format_user_error(error))); .catch(this.$advent22.alert_user_error);
} }
public modal_handle(modal: MultiModal) { public modal_handle(modal: MultiModal) {

View file

@ -27,7 +27,7 @@ export default class extends Vue {
this.doors.push(Door.load(value)); this.doors.push(Door.load(value));
} }
}) })
.catch((error) => alert(this.$advent22.format_user_error(error))); .catch(this.$advent22.alert_user_error);
} }
} }
</script> </script>

View file

@ -116,7 +116,7 @@ export default class extends Vue {
resolve(); resolve();
}) })
.catch((error) => { .catch((error) => {
alert(this.$advent22.format_user_error(error)); this.$advent22.alert_user_error(error);
reject(); reject();
}); });
}); });
@ -134,7 +134,7 @@ export default class extends Vue {
.api_put("admin/doors", data) .api_put("admin/doors", data)
.then(resolve) .then(resolve)
.catch((error) => { .catch((error) => {
alert(this.$advent22.format_user_error(error)); this.$advent22.alert_user_error(error);
reject(); reject();
}); });
}); });

View file

@ -77,6 +77,10 @@ export class Advent22 {
return result(); return result();
} }
public alert_user_error(param: [unknown, string]): void {
alert(this.format_user_error(param));
}
public api_url(): string; public api_url(): string;
public api_url(endpoint: string): string; public api_url(endpoint: string): string;
public api_url(endpoint?: string): string { public api_url(endpoint?: string): string {