Kami commented on a change in pull request #1478:
URL: https://github.com/apache/libcloud/pull/1478#discussion_r464069677



##########
File path: libcloud/container/drivers/lxd.py
##########
@@ -662,10 +730,17 @@ def destroy_container(self, container, 
ex_timeout=default_time_out):
 
         # Return: background operation or standard error
         req = '/%s/containers/%s' % (self.version, container.name)
-        response = self.connection.request(req, method='DELETE')
 
-        response_dict = response.parse_body()
-        assert_response(response_dict=response_dict, status_code=100)
+        try:
+            response = self.connection.request(req, method='DELETE')
+
+            response_dict = response.parse_body()
+            assert_response(response_dict=response_dict, status_code=100)
+        except BaseHTTPError as e:
+            # handle the case where the container is running
+            message_list = e.message.split(",")

Review comment:
       I see this logic duplicated across multiple methods so it would perhaps 
be better to refactor it into some common method - e.g. 
``_get_error_message_for_exception`` or similar.
   
   And some tests for this method would also be good.




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
[email protected]


Reply via email to