Skip to content

Commit

Permalink
fix: now if loading user profile fails an error is thrown instead of …
Browse files Browse the repository at this point in the history
…404ing (#4043)
  • Loading branch information
nickytonline authored Aug 27, 2024
1 parent 6f510cb commit 3527795
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion pages/u/[username]/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import { jsonLdScriptProps } from "react-schemaorg";
import { Person } from "schema-dts";

import { useRouter } from "next/router";
import { captureException } from "@sentry/nextjs";
import SEO from "layouts/SEO/SEO";

import useContributorPullRequests from "lib/hooks/api/useContributorPullRequests";
Expand Down Expand Up @@ -118,7 +119,15 @@ export const getServerSideProps = async (context: UserSSRPropsContext) => {
});

if (!req.ok) {
return { notFound: true };
if (req.status === 404) {
return {
notFound: true,
};
}

const errorText = `Failed to load user profile: ${username}`;
captureException(new Error(errorText, { cause: req.statusText }));
throw new Error(errorText);
}

const userData = (await req.json()) as DbUser;
Expand Down

0 comments on commit 3527795

Please sign in to comment.