From 77e7b56688b4ea232f8390e34fa70207dfc7a161 Mon Sep 17 00:00:00 2001 From: mufaddal motiwala Date: Mon, 20 Dec 2021 12:01:17 +0530 Subject: [PATCH] add Response Error from backstage/erros Signed-off-by: mufaddal motiwala --- plugins/newrelic-dashboard/package.json | 1 + .../newrelic-dashboard/src/api/NewRelicDashboardClient.ts | 7 ++++++- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/plugins/newrelic-dashboard/package.json b/plugins/newrelic-dashboard/package.json index 4f16d3a103..a2d334f480 100644 --- a/plugins/newrelic-dashboard/package.json +++ b/plugins/newrelic-dashboard/package.json @@ -23,6 +23,7 @@ "@backstage/catalog-model": "^0.9.8", "@backstage/core-components": "^0.8.1", "@backstage/core-plugin-api": "^0.3.1", + "@backstage/errors": "^0.1.5", "@backstage/plugin-catalog-react": "^0.6.7", "@material-ui/core": "^4.12.2", "@material-ui/icons": "^4.9.1", diff --git a/plugins/newrelic-dashboard/src/api/NewRelicDashboardClient.ts b/plugins/newrelic-dashboard/src/api/NewRelicDashboardClient.ts index 5a092995f1..5dc42c3711 100644 --- a/plugins/newrelic-dashboard/src/api/NewRelicDashboardClient.ts +++ b/plugins/newrelic-dashboard/src/api/NewRelicDashboardClient.ts @@ -23,6 +23,7 @@ import { DashboardEntity } from '../types/DashboardEntity'; import { DashboardSnapshot } from '../types/DashboardSnapshot'; import { getDashboardParentGuidQuery } from '../queries/getDashboardParentGuidQuery'; import { getDashboardSnapshotQuery } from '../queries/getDashboardSnapshotQuery'; +import { ResponseError } from '@backstage/errors'; export class NewRelicDashboardClient implements NewRelicDashboardApi { private readonly discoveryApi: DiscoveryApi; @@ -59,7 +60,11 @@ export class NewRelicDashboardClient implements NewRelicDashboardApi { if (response.status === 200) { return (await response.json()) as T; } - return undefined; + if (!response.ok) { + throw await ResponseError.fromResponse(response); + } else { + return undefined; + } } async getDashboardEntity(