Throw only on 404 responses

Signed-off-by: Yevhenii Huselietov <yevhenii.huselietov@gmail.com>
This commit is contained in:
Yevhenii Huselietov
2023-10-01 16:51:11 +03:00
parent f41099bb31
commit a8a749e4c4
2 changed files with 8 additions and 4 deletions
@@ -396,7 +396,9 @@ describe('publish:gitlab', () => {
it('should show proper error message when token has insufficient permissions or namespace not found', async () => {
mockGitlabClient.Namespaces.show.mockRejectedValue({
message: '404 Namespace Not Found',
response: {
statusCode: 404,
},
});
const owner = 'infrastructure/devex';
const repoName = 'backstage';
@@ -183,9 +183,11 @@ export function createPublishGitlabAction(options: {
targetNamespaceId = namespaceResponse.id;
} catch (e) {
throw new InputError(
`The namespace ${owner} is not found or the user doesn't have permissions to access it`,
);
if (e.response && e.response.statusCode === 404) {
throw new InputError(
`The namespace ${owner} is not found or the user doesn't have permissions to access it`,
);
}
}
const { id: userId } = (await client.Users.current()) as {