File tree 2 files changed +12
-1
lines changed 2 files changed +12
-1
lines changed Original file line number Diff line number Diff line change @@ -88,3 +88,6 @@ export const getErrorDetail = (error: unknown): string | undefined | null =>
88
88
: error instanceof Error
89
89
? `Please check the developer console for more details.`
90
90
: null
91
+
92
+ export const isAuthenticationError = ( error : unknown ) : boolean =>
93
+ isApiError ( error ) && error . response . status === 401
Original file line number Diff line number Diff line change 1
1
import { AlertProps , Alert , AlertDetail } from "./Alert"
2
2
import AlertTitle from "@mui/material/AlertTitle"
3
- import { getErrorMessage , getErrorDetail } from "api/errors"
3
+ import {
4
+ getErrorMessage ,
5
+ getErrorDetail ,
6
+ isAuthenticationError ,
7
+ } from "api/errors"
4
8
import { FC } from "react"
5
9
6
10
export const ErrorAlert : FC <
7
11
Omit < AlertProps , "severity" | "children" > & { error : unknown }
8
12
> = ( { error, ...alertProps } ) => {
13
+ if ( isAuthenticationError ( error ) ) {
14
+ location . href = "/login"
15
+ }
16
+
9
17
const message = getErrorMessage ( error , "Something went wrong." )
10
18
const detail = getErrorDetail ( error )
11
19
You can’t perform that action at this time.
0 commit comments