[docs]classGrabError(Exception):""" All custom Grab exception should be children of that class. """
classOriginalExceptionError(object):""" Exception sub-class which constructor accepts original exception as second argument """def__init__(self,*args,**kwargs):iflen(args)>1:self.original_exc=args[1]else:self.original_exc=Nonesuper(OriginalExceptionError,self).__init__(*args,**kwargs)
[docs]classGrabNetworkError(OriginalExceptionError,GrabError):""" Raises in case of network error. """
[docs]classGrabTimeoutError(GrabNetworkError):""" Raises when configured time is outed for the request. In curl transport it is CURLE_OPERATION_TIMEDOUT (28) """
[docs]classGrabConnectionError(GrabNetworkError):""" Raised when it is not possible to establish network connection. In curl transport it is CURLE_COULDNT_CONNECT (7) """
classGrabCouldNotResolveHostError(GrabNetworkError):""" URLE_COULDNT_RESOLVE_HOST (6) Couldn't resolve host. The given remote host was not resolved. """
[docs]classGrabAuthError(GrabError):""" Raised when remote server denies authentication credentials. In curl transport it is CURLE_COULDNT_CONNECT (67) """
[docs]classGrabMisuseError(GrabError):""" Indicates incorrect usage of grab API. """
[docs]classGrabTooManyRedirectsError(GrabError):""" Raised when Grab reached max. allowd number of redirects for one request. """
[docs]classGrabInvalidUrl(GrabError):""" Raised when Grab have no idea how to handle the URL or when some error occurred while normalizing URL e.g. IDN processing. """