explorer: fix epoch page failure state (#21068)

This commit is contained in:
Justin Starry 2021-10-29 16:01:49 +01:00 committed by GitHub
parent a8d78e89d3
commit 78d99b89c0
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 6 additions and 2 deletions

View File

@ -8,6 +8,7 @@ import { Epoch } from "components/common/Epoch";
import { Slot } from "components/common/Slot";
import { useEpoch, useFetchEpoch } from "providers/epoch";
import { displayTimestampUtc } from "utils/date";
import { FetchStatus } from "providers/cache";
type Props = { epoch: string };
export function EpochDetailsPage({ epoch }: Props) {
@ -58,6 +59,9 @@ function EpochOverviewCard({ epoch }: OverviewProps) {
if (epoch > currentEpoch) {
return <ErrorCard text={`Epoch ${epoch} hasn't started yet`} />;
} else if (!epochState?.data) {
if (epochState?.status === FetchStatus.FetchFailed) {
return <ErrorCard text={`Failed to fetch details for epoch ${epoch}`} />;
}
return <LoadingCard message="Loading epoch" />;
}

View File

@ -1,8 +1,8 @@
import React from "react";
import * as Sentry from "@sentry/react";
import * as Cache from "providers/cache";
import { Connection, EpochSchedule } from "@solana/web3.js";
import { useCluster, Cluster } from "./cluster";
import { reportError } from "utils/sentry";
export enum FetchStatus {
Fetching,
@ -121,7 +121,7 @@ export async function fetchEpoch(
} catch (err) {
status = FetchStatus.FetchFailed;
if (cluster !== Cluster.Custom) {
Sentry.captureException(err, { tags: { url } });
reportError(err, { epoch: epoch.toString() });
}
}