From 4239b8dba6c490bc7cc97722e43c9699e3d849bf Mon Sep 17 00:00:00 2001 From: Karan Shah Date: Thu, 3 Mar 2022 15:15:58 +0000 Subject: [PATCH] Don't check exceptions Signed-off-by: Karan Shah --- .../EntityAirbrakeWidget.test.tsx | 2 +- .../EntityAirbrakeWidget.tsx | 26 +++---------------- 2 files changed, 5 insertions(+), 23 deletions(-) diff --git a/plugins/airbrake/src/components/EntityAirbrakeWidget/EntityAirbrakeWidget.test.tsx b/plugins/airbrake/src/components/EntityAirbrakeWidget/EntityAirbrakeWidget.test.tsx index 6211500b10..64f1f11223 100644 --- a/plugins/airbrake/src/components/EntityAirbrakeWidget/EntityAirbrakeWidget.test.tsx +++ b/plugins/airbrake/src/components/EntityAirbrakeWidget/EntityAirbrakeWidget.test.tsx @@ -34,7 +34,7 @@ import { errorApiRef } from '@backstage/core-plugin-api'; import { rest } from 'msw'; import { setupServer } from 'msw/node'; -describe('EntityAirbrakeContent', () => { +describe('EntityAirbrakeWidget', () => { const worker = setupServer(); setupRequestMockHandlers(worker); diff --git a/plugins/airbrake/src/components/EntityAirbrakeWidget/EntityAirbrakeWidget.tsx b/plugins/airbrake/src/components/EntityAirbrakeWidget/EntityAirbrakeWidget.tsx index 327da881a3..29260427a9 100644 --- a/plugins/airbrake/src/components/EntityAirbrakeWidget/EntityAirbrakeWidget.tsx +++ b/plugins/airbrake/src/components/EntityAirbrakeWidget/EntityAirbrakeWidget.tsx @@ -29,7 +29,6 @@ import { ErrorApi, errorApiRef, useApi } from '@backstage/core-plugin-api'; import { airbrakeApiRef } from '../../api'; import useAsync from 'react-use/lib/useAsync'; import { AIRBRAKE_PROJECT_ID_ANNOTATION, useProjectId } from '../useProjectId'; -import { NoProjectIdError } from '../../api/AirbrakeApi'; const useStyles = makeStyles(() => ({ multilineText: { @@ -54,38 +53,21 @@ export const EntityAirbrakeWidget = ({ entity }: { entity: Entity }) => { ComponentState.Loading, ); - useEffect(() => { - if (!projectId) { - setComponentState(ComponentState.NoProjectId); - } else { - setComponentState(ComponentState.Loading); - } - }, [projectId]); - - const { loading, value, error } = useAsync(async () => { + const { loading, value } = useAsync(async () => { try { const result = await airbrakeApi.fetchGroups(projectId); setComponentState(ComponentState.Loaded); return result; } catch (e) { - if (e instanceof NoProjectIdError) { + if (!projectId) { setComponentState(ComponentState.NoProjectId); } else { setComponentState(ComponentState.Error); + errorApi.post(e); } throw e; } - }, [airbrakeApi, projectId]); - - useEffect(() => { - if ( - componentState === ComponentState.Error && - error && - !(error instanceof NoProjectIdError) - ) { - errorApi.post(error); - } - }, [componentState, error, errorApi]); + }, [airbrakeApi, errorApi, projectId]); useEffect(() => { if (loading) {