Skip to content

Commit 994690b

Browse files
authored
improve error handling when adding repos (#4623)
1 parent f8d7360 commit 994690b

File tree

1 file changed

+11
-5
lines changed

1 file changed

+11
-5
lines changed

src/sentry/plugins/providers/repository.py

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
from rest_framework.response import Response
55

66
from sentry.api.serializers import serialize
7+
from sentry.exceptions import PluginError
78
from sentry.models import Repository
89
from sentry.plugins.config import ConfigValidator
910

@@ -46,11 +47,16 @@ def dispatch(self, request, organization, **kwargs):
4647
except Exception as e:
4748
return self.handle_api_error(e)
4849

49-
result = self.create_repository(
50-
organization=organization,
51-
data=config,
52-
actor=request.user,
53-
)
50+
try:
51+
result = self.create_repository(
52+
organization=organization,
53+
data=config,
54+
actor=request.user,
55+
)
56+
except PluginError as e:
57+
return Response({
58+
'errors': {'__all__': e.message},
59+
}, status=400)
5460

5561
repo = Repository.objects.create(
5662
organization_id=organization.id,

0 commit comments

Comments
 (0)