[bugfix/frontend] Fix TypeError: gtsError is undefined (#3245)

This commit is contained in:
tobi 2024-08-27 12:39:26 +02:00 committed by GitHub
parent 2db5a51582
commit 1f3dfbf10c
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -79,10 +79,15 @@ function Error({ error, reset }: ErrorProps) {
let message: ReactNode;
if ("status" in error) {
// RTK Query error with data.
if (typeof error.status === "number") {
// Error containing GTS API error data.
const gtsError = error.data as GtsError;
const errMsg = gtsError.error_description ?? gtsError.error;
message = <>Code {error.status} {errMsg}</>;
message = <>Code {error.status}: {errMsg}</>;
} else {
// RTK Query fetching / parsing / timeout error.
message = <>{error.status}: {error.error}</>;
}
} else {
// SerializedError or Error.
const errMsg = error.message ?? JSON.stringify(error);