add Response Error from backstage/erros

Signed-off-by: mufaddal motiwala <mufaddalmm.52@gmail.com>
This commit is contained in:
mufaddal motiwala
2021-12-20 12:01:17 +05:30
parent 7caba057c8
commit 77e7b56688
2 changed files with 7 additions and 1 deletions
+1
View File
@@ -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",
@@ -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(