Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Merged
merged 1 commit into from
Aug 27, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 9 additions & 4 deletions web/source/settings/components/error.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -79,10 +79,15 @@ function Error({ error, reset }: ErrorProps) {

let message: ReactNode;
if ("status" in error) {
// RTK Query error with data.
const gtsError = error.data as GtsError;
const errMsg = gtsError.error_description ?? gtsError.error;
message = <>Code {error.status} {errMsg}</>;
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}</>;
} else {
// RTK Query fetching / parsing / timeout error.
message = <>{error.status}: {error.error}</>;
}
} else {
// SerializedError or Error.
const errMsg = error.message ?? JSON.stringify(error);
Expand Down