Merge pull request #4289 from backstage/rugvip/errors

integration: forward errors from gitlab project lookups
This commit is contained in:
Patrik Oldsberg
2021-01-28 18:31:42 +01:00
committed by GitHub
2 changed files with 13 additions and 3 deletions
+5
View File
@@ -0,0 +1,5 @@
---
'@backstage/integration': patch
---
Properly forward errors that occur when looking up GitLab project IDs.
+8 -3
View File
@@ -147,10 +147,15 @@ export async function getProjectId(
repoIDLookup.toString(),
getGitLabRequestOptions(config),
);
const projectIDJson = await response.json();
const projectID = Number(projectIDJson.id);
const data = await response.json();
return projectID;
if (!response.ok) {
throw new Error(
`GitLab Error '${data.error}', ${data.error_description}`,
);
}
return Number(data.id);
} catch (e) {
throw new Error(`Could not get GitLab project ID for: ${target}, ${e}`);
}