[ 
https://issues.apache.org/jira/browse/LIBCLOUD-114?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13114965#comment-13114965
 ] 

Brian Hoenig commented on LIBCLOUD-114:
---------------------------------------

Sure, this is to handle and response from a provider that fails the drivers 
success test.

A good example is attempting to save an image on a node that is busy:
------------------
In [8]: lcProvider.ex_save_image(lcNode,'spam')
Out[8]: <NodeImage: id=10246636, name=spam, driver=Rackspace (UK)  ...>

In [9]: lcProvider.ex_save_image(lcNode,'spam')

......
Exception: 400 Bad Request 422 Unprocessable Entity: Cannot create a new backup 
request while saving a prior backup or migrating.; 
com.rackspace.cloud.service.servers.CloudServersFault: Fault occured
---------------------

The response information is valuable and has to be parsed from a string, and 
that string is currently constructed differently for every provider. It would 
be nice for the caller to get that code in a uniform way across providers.  I 
understand that this can be handled with a custom response class (and is for 
auth errors in a variety of ways for some providers), but it would be much more 
useful and keep things more consistent to propagate the provider response.  The 
 new exception class would allow things like this:


--------------------------

In [18]: try:
   ....:     lcNode.id = "23676"
   ....:     lcProvider.ex_save_image(lcNode,'spam')
   ....: except ProviderHTTPResponseError, e:
   ....:     print str(e)
   ....:     print
   ....:     print "Code: %s" % e.http_error_code
   ....:     print
   ....:     print "Message: %s" % e.http_error_message
   ....:     

404 Not Found Not Found; com.rackspace.cloud.service.servers.ItemNotFoundFault: 
 Not Found

Code: 404

Message: Not Found

-----------------------
                
> Provider HTTP Error responses need to be propagated in a better way.
> --------------------------------------------------------------------
>
>                 Key: LIBCLOUD-114
>                 URL: https://issues.apache.org/jira/browse/LIBCLOUD-114
>             Project: Libcloud
>          Issue Type: Improvement
>          Components: Core
>            Reporter: Brian Hoenig
>            Priority: Minor
>   Original Estimate: 24h
>  Remaining Estimate: 24h
>
> Currently when a provider returns an unexpected (error) response the response 
> code and message must be parsed from a message string in a base Exception.  
> Instead we should include the error code and error message in an exception 
> class (ProviderHTTPResponseError).

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: 
https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

Reply via email to