Skip to content

Commit bea8963

Browse files
author
Gabriel Monroy
committed
handle no credentials error on formation/node destroy
1 parent 0a47d7c commit bea8963

1 file changed

Lines changed: 8 additions & 2 deletions

File tree

api/views.py

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -244,7 +244,10 @@ def run(self, request, **kwargs):
244244

245245
def destroy(self, request, **kwargs):
246246
formation = self.get_object()
247-
formation.destroy()
247+
try:
248+
formation.destroy()
249+
except EnvironmentError as e:
250+
return Response(str(e), status=HTTP_400_BAD_REQUEST)
248251
formation.delete()
249252
return Response(status=status.HTTP_204_NO_CONTENT)
250253

@@ -311,7 +314,10 @@ def get_object(self, *args, **kwargs):
311314

312315
def destroy(self, request, **kwargs):
313316
node = self.get_object()
314-
node.destroy()
317+
try:
318+
node.destroy()
319+
except EnvironmentError as e:
320+
return Response(str(e), status=HTTP_400_BAD_REQUEST)
315321
return Response(status=status.HTTP_204_NO_CONTENT)
316322

317323

0 commit comments

Comments
 (0)