Throw errors when response is not ok
Signed-off-by: Julio Zynger <julio.zynger@soundcloud.com>
This commit is contained in:
@@ -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",
|
||||
|
||||
@@ -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();
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user