Show error on task page if task does not exist

Signed-off-by: Oliver Sand <oliver.sand@sda-se.com>
This commit is contained in:
Oliver Sand
2021-05-06 17:50:30 +02:00
parent 0bfcc4323a
commit 81ef1d57bf
3 changed files with 15 additions and 2 deletions
+5
View File
@@ -0,0 +1,5 @@
---
'@backstage/plugin-scaffolder': patch
---
Show error on task page if task does not exist.
+1
View File
@@ -33,6 +33,7 @@
"@backstage/catalog-client": "^0.3.11",
"@backstage/catalog-model": "^0.7.8",
"@backstage/config": "^0.1.5",
"@backstage/errors": "^0.1.1",
"@backstage/core": "^0.7.8",
"@backstage/integration": "^0.5.2",
"@backstage/integration-react": "^0.1.1",
+9 -2
View File
@@ -22,6 +22,7 @@ import {
IdentityApi,
Observable,
} from '@backstage/core';
import { ResponseError } from '@backstage/errors';
import { ScmIntegrationRegistry } from '@backstage/integration';
import ObservableImpl from 'zen-observable';
import { ListActionsResponse, ScaffolderTask, Status } from './types';
@@ -173,9 +174,15 @@ export class ScaffolderClient implements ScaffolderApi {
const token = await this.identityApi.getIdToken();
const baseUrl = await this.discoveryApi.getBaseUrl('scaffolder');
const url = `${baseUrl}/v2/tasks/${encodeURIComponent(taskId)}`;
return fetch(url, {
const response = await fetch(url, {
headers: token ? { Authorization: `Bearer ${token}` } : {},
}).then(x => x.json());
});
if (!response.ok) {
throw ResponseError.fromResponse(response);
}
return await response.json();
}
streamLogs({