Refactoring Error Screen

This commit is contained in:
CEC
2022-04-12 10:23:36 +02:00
parent a689756d85
commit 748baa9bbc
19 changed files with 315 additions and 61 deletions
@@ -3,7 +3,6 @@ import Image = Phaser.GameObjects.Image;
import Sprite = Phaser.GameObjects.Sprite;
import Text = Phaser.GameObjects.Text;
import ScenePlugin = Phaser.Scenes.ScenePlugin;
import { WAError } from "./WAError";
import Axios from "axios";
export const ErrorSceneName = "ErrorScene";
@@ -88,12 +87,6 @@ export class ErrorScene extends Phaser.Scene {
title: "An error occurred",
subTitle: error,
});
} else if (error instanceof WAError) {
scene.start(ErrorSceneName, {
title: error.title,
subTitle: error.subTitle,
message: error.details,
});
} else if (Axios.isAxiosError(error) && error.response) {
// Axios HTTP error
// client received an error response (5xx, 4xx)
+37 -8
View File
@@ -1,26 +1,55 @@
export class WAError extends Error {
private _type: string;
private _code: string;
private _title: string;
private _subTitle: string;
private _subtitle: string;
private _details: string;
private _timeToRetry:number;
private _canRetryManual: boolean;
private _urlToRedirect: string;
private _buttonTitle: string;
constructor(title: string, subTitle: string, details: string) {
super(title + " - " + subTitle + " - " + details);
constructor(type: string, code: string, title: string, subtitle: string, details: string, timeToRetry: number, canRetryManual: boolean, urlToRedirect: string, buttonTitle: string) {
super(title + " - " + subtitle + " - " + details);
this._type = type;
this._code = code;
this._title = title;
this._subTitle = subTitle;
this._subtitle = subtitle;
this._details = details;
this._timeToRetry = timeToRetry;
this._canRetryManual = canRetryManual;
this._urlToRedirect = urlToRedirect;
this._buttonTitle = buttonTitle;
// Set the prototype explicitly.
Object.setPrototypeOf(this, WAError.prototype);
}
get type(): string {
return this._type;
}
get code(): string {
return this._code;
}
get title(): string {
return this._title;
}
get subTitle(): string {
return this._subTitle;
get subtitle(): string {
return this._subtitle;
}
get details(): string {
return this._details;
}
get timeToRetry(): number {
return this._timeToRetry;
}
get buttonTitle(): string {
return this._buttonTitle;
}
get urlToRedirect(): string {
return this._urlToRedirect;
}
get canRetryManual(): boolean {
return this._canRetryManual;
}
}