How to use the hubspot3.error.HubspotError function in hubspot3

To help you get started, we’ve selected a few hubspot3 examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github jpetrucciani / hubspot3 / hubspot3 / base.py View on Github external
params=params,
                        method=method,
                        data=data,
                        doseq=doseq,
                        query=query,
                        retried=True,
                        **options
                    )
                if self.access_token:
                    self.log.warning(
                        "In order to enable automated refreshing of your access token, please "
                        "provide a client ID, client secret and refresh token in addition to the "
                        "access token."
                    )
                raise
            except HubspotError as exception:
                if try_count > num_retries:
                    logging.warning("Too many retries for {}".format(url))
                    raise
                # Don't retry errors from 300 to 499
                if exception.result and 300 <= exception.result.status < 500:
                    raise
                self._prepare_request_retry(method, url, headers, data)
                self.log.warning(
                    "HubspotError {} calling {}, retrying".format(exception, url)
                )
            # exponential back off
            # wait 0 seconds, 1 second, 3 seconds, 7 seconds, 15 seconds, etc
            time.sleep((pow(2, try_count - 1) - 1) * self.sleep_multiplier)
        return result
github jpetrucciani / hubspot3 / hubspot3 / error.py View on Github external
# Create more specific error cases, to make filtering errors easier
class HubspotBadRequest(HubspotError):
    """most 40X results and 501 results"""


class HubspotNotFound(HubspotError):
    """404 and 410 results"""


class HubspotTimeout(HubspotError):
    """socket timeouts, sslerror, and 504"""


class HubspotUnauthorized(HubspotError):
    """401 Unauthorized errors"""


class HubspotConflict(HubspotError):
    """409 conflict errors"""


class HubspotServerError(HubspotError):
    """most 500 errors"""


class HubspotRateLimited(HubspotError):
    """exception for when we're rate limited"""
github jpetrucciani / hubspot3 / hubspot3 / error.py View on Github external
unicode_data[key] = val
            else:
                unicode_data[key] = str(type(val))
        return unicode_data


class HubspotBadConfig(Exception):
    """misconfigured api_key and/or access_token credentials client"""


class HubspotNoConfig(Exception):
    """no api_key or access_token credentials were passed to the client"""


# Create more specific error cases, to make filtering errors easier
class HubspotBadRequest(HubspotError):
    """most 40X results and 501 results"""


class HubspotNotFound(HubspotError):
    """404 and 410 results"""


class HubspotTimeout(HubspotError):
    """socket timeouts, sslerror, and 504"""


class HubspotUnauthorized(HubspotError):
    """401 Unauthorized errors"""


class HubspotConflict(HubspotError):
github jpetrucciani / hubspot3 / hubspot3 / error.py View on Github external
class HubspotNoConfig(Exception):
    """no api_key or access_token credentials were passed to the client"""


# Create more specific error cases, to make filtering errors easier
class HubspotBadRequest(HubspotError):
    """most 40X results and 501 results"""


class HubspotNotFound(HubspotError):
    """404 and 410 results"""


class HubspotTimeout(HubspotError):
    """socket timeouts, sslerror, and 504"""


class HubspotUnauthorized(HubspotError):
    """401 Unauthorized errors"""


class HubspotConflict(HubspotError):
    """409 conflict errors"""


class HubspotServerError(HubspotError):
    """most 500 errors"""


class HubspotRateLimited(HubspotError):
github jpetrucciani / hubspot3 / hubspot3 / error.py View on Github external
"""most 40X results and 501 results"""


class HubspotNotFound(HubspotError):
    """404 and 410 results"""


class HubspotTimeout(HubspotError):
    """socket timeouts, sslerror, and 504"""


class HubspotUnauthorized(HubspotError):
    """401 Unauthorized errors"""


class HubspotConflict(HubspotError):
    """409 conflict errors"""


class HubspotServerError(HubspotError):
    """most 500 errors"""


class HubspotRateLimited(HubspotError):
    """exception for when we're rate limited"""
github jpetrucciani / hubspot3 / hubspot3 / error.py View on Github external
def __init__(self, result, request, err=None):
        super(HubspotError, self).__init__(result and result.reason or "Unknown Reason")
        if result is None:
            self.result = EmptyResult()
        else:
            self.result = result
        if request is None:
            request = {}
        self.request = request
        self.err = err
github jpetrucciani / hubspot3 / hubspot3 / error.py View on Github external
class HubspotBadConfig(Exception):
    """misconfigured api_key and/or access_token credentials client"""


class HubspotNoConfig(Exception):
    """no api_key or access_token credentials were passed to the client"""


# Create more specific error cases, to make filtering errors easier
class HubspotBadRequest(HubspotError):
    """most 40X results and 501 results"""


class HubspotNotFound(HubspotError):
    """404 and 410 results"""


class HubspotTimeout(HubspotError):
    """socket timeouts, sslerror, and 504"""


class HubspotUnauthorized(HubspotError):
    """401 Unauthorized errors"""


class HubspotConflict(HubspotError):
    """409 conflict errors"""


class HubspotServerError(HubspotError):
github jpetrucciani / hubspot3 / hubspot3 / settings.py View on Github external
def delete_setting(self, name: str, **options):
        """Deletes a specific setting by emptying out its value."""
        params = {}
        if name:
            params["name"] = name
        else:
            raise HubspotError("Setting name required.", "settings")
        return self._call("settings", params=params, method="DELETE", **options)
github jpetrucciani / hubspot3 / hubspot3 / error.py View on Github external
"""404 and 410 results"""


class HubspotTimeout(HubspotError):
    """socket timeouts, sslerror, and 504"""


class HubspotUnauthorized(HubspotError):
    """401 Unauthorized errors"""


class HubspotConflict(HubspotError):
    """409 conflict errors"""


class HubspotServerError(HubspotError):
    """most 500 errors"""


class HubspotRateLimited(HubspotError):
    """exception for when we're rate limited"""
github jpetrucciani / hubspot3 / hubspot3 / error.py View on Github external
"""socket timeouts, sslerror, and 504"""


class HubspotUnauthorized(HubspotError):
    """401 Unauthorized errors"""


class HubspotConflict(HubspotError):
    """409 conflict errors"""


class HubspotServerError(HubspotError):
    """most 500 errors"""


class HubspotRateLimited(HubspotError):
    """exception for when we're rate limited"""