diff --git a/web/src/flows/FlowExecutor.ts b/web/src/flows/FlowExecutor.ts index 5f87ac2a2..3292b8838 100644 --- a/web/src/flows/FlowExecutor.ts +++ b/web/src/flows/FlowExecutor.ts @@ -107,8 +107,8 @@ export class FlowExecutor extends LitElement implements StageHost { }).then((data) => { this.challenge = data; this.postUpdate(); - }).catch((e: Error) => { - this.errorMessage(e.toString()); + }).catch((e: Error | Response) => { + this.errorMessage(e); }).finally(() => { this.loading = false; }); @@ -128,15 +128,21 @@ export class FlowExecutor extends LitElement implements StageHost { this.setBackground(this.challenge.flowInfo.background); } this.postUpdate(); - }).catch((e: Error) => { + }).catch((e: Error | Response) => { // Catch JSON or Update errors - this.errorMessage(e.toString()); + this.errorMessage(e); }).finally(() => { this.loading = false; }); } - errorMessage(error: string): void { + async errorMessage(error: Error | Response): Promise { + let body = ""; + if (error instanceof Error) { + body = error.message; + } else if (error instanceof Response) { + body = await error.text(); + } this.challenge = { type: ChallengeChoices.Shell, body: `
@@ -146,7 +152,7 @@ export class FlowExecutor extends LitElement implements StageHost {

${t`Something went wrong! Please try again later.`}

-
${error}
+
${body}