Skip to content

Add new handled exceptions #17773

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 8 commits into from
Jun 11, 2024
Merged
1 change: 1 addition & 0 deletions openstack_controller/changelog.d/17773.added
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Add new handled exceptions
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,10 @@
from enum import Enum, unique
from functools import wraps

from requests.exceptions import HTTPError
import requests

from datadog_checks.base import AgentCheck
from datadog_checks.openstack_controller.api.catalog import CatalogEndPointFailure


def argument_value(arg_name, func, *args, **kwargs):
Expand Down Expand Up @@ -75,10 +76,12 @@ def wrapper(self, *args, **kwargs):
tags = argument_value('tags', func, *args, **kwargs)
self.check.service_check(self.SERVICE_CHECK, AgentCheck.OK, tags=tags)
return result if result is not None else True
except HTTPError as e:
self.check.log.error("HTTPError: %s", e.response)
except (requests.HTTPError, requests.ConnectionError, requests.Timeout, requests.RequestException) as e:
self.check.log.debug("HTTPError: %s", e.response)
if report_service_check:
self.check.service_check(self.SERVICE_CHECK, AgentCheck.CRITICAL, tags=tags)
except CatalogEndPointFailure as e:
self.check.log.debug("CatalogEndPointFailure: %s", e)
except Exception as e:
self.check.log.error("Exception: %s", e)
return None
Expand Down
Loading