Commit a37166c3 by jsa Committed by Andy Armstrong

remove catchall exception handling in profile image api

parent bb2599ce
......@@ -223,12 +223,8 @@ class ProfileImageUploadTestCase(ProfileImageEndpointTestCase):
"""
image_open.side_effect = [Exception(u"whoops"), None]
with make_image_file() as image_file:
response = self.client.post(self.url, {'file': image_file}, format='multipart')
self.check_response(
response, 400,
expected_developer_message=u"Upload failed for profile image: whoops",
expected_user_message=u"Upload failed for profile image",
)
with self.assertRaises(Exception):
self.client.post(self.url, {'file': image_file}, format='multipart')
self.check_images(False)
self.check_has_profile_image(False)
self.assertFalse(mock_log.info.called)
......@@ -321,12 +317,8 @@ class ProfileImageRemoveTestCase(ProfileImageEndpointTestCase):
messages are returned.
"""
user_profile_save.side_effect = [Exception(u"whoops"), None]
response = self.client.post(self.url)
self.check_response(
response, 400,
expected_developer_message=u"Delete failed for profile image: whoops",
expected_user_message=u"Delete failed for profile image",
)
with self.assertRaises(Exception):
self.client.post(self.url)
self.check_images(True) # thumbnails should remain intact.
self.check_has_profile_image(True)
self.assertFalse(mock_log.info.called)
......@@ -80,7 +80,6 @@ class ProfileImageUploadView(APIView):
status=status.HTTP_400_BAD_REQUEST
)
try:
# process the upload.
uploaded_file = request.FILES['file']
......@@ -107,15 +106,6 @@ class ProfileImageUploadView(APIView):
LOG_MESSAGE_CREATE,
{'image_names': profile_image_names.values(), 'user_id': request.user.id}
)
except Exception as error:
return Response(
{
"developer_message": u"Upload failed for profile image: {error}".format(error=error),
"user_message": _(u"Upload failed for profile image"),
},
status=status.HTTP_400_BAD_REQUEST
)
# send client response.
return Response(status=status.HTTP_204_NO_CONTENT)
......@@ -165,15 +155,6 @@ class ProfileImageRemoveView(APIView):
)
except UserNotFound:
return Response(status=status.HTTP_404_NOT_FOUND)
except Exception as error:
return Response(
{
"developer_message": u"Delete failed for profile image: {error}".format(error=error),
"user_message": _(u"Delete failed for profile image"),
},
status=status.HTTP_400_BAD_REQUEST
)
# send client response.
return Response(status=status.HTTP_204_NO_CONTENT)
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment