feat(web): add error pages (#193)

This commit is contained in:
41666 2021-03-22 21:18:56 -04:00 committed by GitHub
parent f4165f8055
commit a5f819bc3e
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 23 additions and 3 deletions

View file

@ -0,0 +1,10 @@
import { Error } from '@roleypoly/design-system/templates/errors';
import { useAppShellProps } from '../contexts/app-shell/AppShellContext';
const ErrorPage = (props: { identity: string }) => {
const appShellProps = useAppShellProps();
return <Error code={props.identity} {...appShellProps} />;
};
export default ErrorPage;

View file

@ -56,8 +56,10 @@ const Picker = (props: PickerProps) => {
if (pickerData === false) {
if (session && session.user && session.guilds) {
const guildSlug = session.guilds.find((guild) => guild.id === props.serverID);
if (!guildSlug) {
throw new Error('placeholder: guild not found in user slugs, 404');
console.error({ error: 'guold not in session, 404' });
return <Redirect to="/error/404" replace />;
}
return (
@ -69,7 +71,8 @@ const Picker = (props: PickerProps) => {
);
}
throw new Error('placeholder: session state is odd, 404');
console.error({ error: 'session state is odd, 404' });
return <Redirect to="/error/404" replace />;
}
const onSubmit = async (submittedRoles: string[]) => {

View file

@ -9,7 +9,7 @@ const ServersPage = () => {
const { isAuthenticated, session } = useSessionContext();
const appShellProps = useAppShellProps();
if (!isAuthenticated || !session) {
return <Redirect to="/" />;
return <Redirect to="/" noThrow />;
}
return (