web/flows: improve display of errors
Signed-off-by: Jens Langhammer <jens.langhammer@beryju.org>
This commit is contained in:
parent
74e4e8f6aa
commit
00cbaaf672
|
@ -107,8 +107,8 @@ export class FlowExecutor extends LitElement implements StageHost {
|
||||||
}).then((data) => {
|
}).then((data) => {
|
||||||
this.challenge = data;
|
this.challenge = data;
|
||||||
this.postUpdate();
|
this.postUpdate();
|
||||||
}).catch((e: Error) => {
|
}).catch((e: Error | Response) => {
|
||||||
this.errorMessage(e.toString());
|
this.errorMessage(e);
|
||||||
}).finally(() => {
|
}).finally(() => {
|
||||||
this.loading = false;
|
this.loading = false;
|
||||||
});
|
});
|
||||||
|
@ -128,15 +128,21 @@ export class FlowExecutor extends LitElement implements StageHost {
|
||||||
this.setBackground(this.challenge.flowInfo.background);
|
this.setBackground(this.challenge.flowInfo.background);
|
||||||
}
|
}
|
||||||
this.postUpdate();
|
this.postUpdate();
|
||||||
}).catch((e: Error) => {
|
}).catch((e: Error | Response) => {
|
||||||
// Catch JSON or Update errors
|
// Catch JSON or Update errors
|
||||||
this.errorMessage(e.toString());
|
this.errorMessage(e);
|
||||||
}).finally(() => {
|
}).finally(() => {
|
||||||
this.loading = false;
|
this.loading = false;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
errorMessage(error: string): void {
|
async errorMessage(error: Error | Response): Promise<void> {
|
||||||
|
let body = "";
|
||||||
|
if (error instanceof Error) {
|
||||||
|
body = error.message;
|
||||||
|
} else if (error instanceof Response) {
|
||||||
|
body = await error.text();
|
||||||
|
}
|
||||||
this.challenge = {
|
this.challenge = {
|
||||||
type: ChallengeChoices.Shell,
|
type: ChallengeChoices.Shell,
|
||||||
body: `<header class="pf-c-login__main-header">
|
body: `<header class="pf-c-login__main-header">
|
||||||
|
@ -146,7 +152,7 @@ export class FlowExecutor extends LitElement implements StageHost {
|
||||||
</header>
|
</header>
|
||||||
<div class="pf-c-login__main-body">
|
<div class="pf-c-login__main-body">
|
||||||
<h3>${t`Something went wrong! Please try again later.`}</h3>
|
<h3>${t`Something went wrong! Please try again later.`}</h3>
|
||||||
<pre class="ak-exception">${error}</pre>
|
<pre class="ak-exception">${body}</pre>
|
||||||
</div>
|
</div>
|
||||||
<footer class="pf-c-login__main-footer">
|
<footer class="pf-c-login__main-footer">
|
||||||
<ul class="pf-c-login__main-footer-links">
|
<ul class="pf-c-login__main-footer-links">
|
||||||
|
|
Reference in New Issue