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

John Carr commented on LIBCLOUD-331:
------------------------------------

I really like this idea. Right now my scripts just can't do reliable exception 
handling for a lot of cases.

I think *service* based errors should be phased out. So no more 
SoftLayerException, LinodeException, etc. I don't think they add any meaningful 
information to a traceback.

There should be more specific and generic exceptions:

 * LoadBalancerDoesNotExistError
 * NodeDoesNotExistError
 * VolumeDoesNotExistError
 * etc

there should be *AlreadyExistsError variants too, as per the DNS interface.

I don't like prefixing generally, I think "LoadBalancerError" is a much better 
name than "LibcloudLBError".

A ValidationError would be good, which would be raised in the __init__ of 
Driver classes. It would be ideal if it could take the name of the parameter 
that caused validation to fail.

For errors from API's that aren't generic we could have an OperationError (is 
this ProviderError?), with either flags or subclasses so that a Driver can 
signal to your code whether or not the issue is recoverable - whether the 
operation should be retried, or whether your script or background task should 
abort.
                
> proposal to add a new error type - ProviderError
> ------------------------------------------------
>
>                 Key: LIBCLOUD-331
>                 URL: https://issues.apache.org/jira/browse/LIBCLOUD-331
>             Project: Libcloud
>          Issue Type: Improvement
>          Components: Core
>    Affects Versions: 0.12.3
>            Reporter: Jayyy V
>            Priority: Minor
>
> libcloud.common.base.Response constructor is handling failures of provider 
> operations, this way
>         if not self.success():
>             raise Exception(self.parse_error())
> for eg., in ec2 driver the parse_error method is overridden to handle 
> specific cases like invalid credentials, malformed responses but all other 
> error cases produced by ec2 will be raised as Exception. Its too generic and 
> we need a classification (ProviderError) to capture all the errors generated 
> by a cloud provider.
> * libcloud.common.base.Response can use it 
>         if not self.success():
>             raise ProviderError(self.parse_error())
> * specific errors of providers can be derived from it
>       class InvalidCredsError(ProviderError):
> Also drivers that are having provider specific error types (eg., 
> SoftLayerException, LinodeException, HostVirtualException) can be extended 
> from ProviderError. Currently its extending LibcloudError and since 
> LibcloudError is inclusive of all internal stuffs, having a separate type for 
> errors occured at provider side would simplify error handling for libcloud 
> clients.

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira

Reply via email to