diff --git a/plugins/gocd/package.json b/plugins/gocd/package.json index aac6d3d297..0af395637b 100644 --- a/plugins/gocd/package.json +++ b/plugins/gocd/package.json @@ -31,6 +31,7 @@ "@backstage/catalog-model": "^0.9.1", "@backstage/core-components": "^0.8.2", "@backstage/core-plugin-api": "^0.4.0", + "@backstage/errors": "^0.1.4", "@backstage/plugin-catalog-react": "^0.6.0", "@backstage/theme": "^0.2.14", "@material-ui/core": "^4.12.2", diff --git a/plugins/gocd/src/api/gocdApi.client.ts b/plugins/gocd/src/api/gocdApi.client.ts index d74cf9e055..1f4955a80d 100644 --- a/plugins/gocd/src/api/gocdApi.client.ts +++ b/plugins/gocd/src/api/gocdApi.client.ts @@ -16,6 +16,7 @@ import { GoCdApi } from './gocdApi'; import { GoCdApiError, PipelineHistory } from './gocdApi.model'; import { DiscoveryApi } from '@backstage/core-plugin-api'; +import { ResponseError } from '@backstage/errors'; export class GoCdClientApi implements GoCdApi { constructor(private readonly discoveryApi: DiscoveryApi) {} @@ -33,6 +34,10 @@ export class GoCdClientApi implements GoCdApi { }, ); + if (!pipelineHistoryResponse.ok) { + throw await ResponseError.fromResponse(pipelineHistoryResponse); + } + return await pipelineHistoryResponse.json(); } }