Throw only on 404 responses
Signed-off-by: Yevhenii Huselietov <yevhenii.huselietov@gmail.com>
This commit is contained in:
@@ -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 {
|
||||
|
||||
Reference in New Issue
Block a user