Skip to content

Commit

Permalink
fix: now if loading user data fails an error is thrown instead of 404ing
Browse files Browse the repository at this point in the history
  • Loading branch information
nickytonline committed Aug 27, 2024
1 parent 0b61b77 commit fddf6e4
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 fddf6e4

Please sign in to comment.