Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
export const useErrorHandler = (
error: unknown,
{ defaultError }: { defaultError: Error }
): void => {
const handler = useReactErrorHandler()
useEffect(() => {
if (!error) {
return
}
if (error instanceof Error) {
Bugsnag.notify(error)
handler(new HandledError(defaultError.message))
} else if (error instanceof Response) {
error
.clone()
.json()
.then((res: { error: APIError }) => {
handler(new HandledError(res.error.message))