diff --git a/airbyte-integrations/connectors/source-google-ads/source_google_ads/source.py b/airbyte-integrations/connectors/source-google-ads/source_google_ads/source.py index 990f5a0e0876..699974ef816a 100644 --- a/airbyte-integrations/connectors/source-google-ads/source_google_ads/source.py +++ b/airbyte-integrations/connectors/source-google-ads/source_google_ads/source.py @@ -89,7 +89,12 @@ def is_metrics_in_custom_query(query: GAQL) -> bool: return False def check_connection(self, logger: logging.Logger, config: Mapping[str, Any]) -> Tuple[bool, any]: - config = self._validate_and_transform(config) + try: + config = self._validate_and_transform(config) + except ValueError as e: + return False, f"error while validating custom query: {repr(e)}" + except Exception as e: + return False, f"error: {repr(e)}" try: logger.info("Checking the config") google_api = GoogleAds(credentials=self.get_credentials(config)) diff --git a/airbyte-integrations/connectors/source-google-ads/source_google_ads/utils.py b/airbyte-integrations/connectors/source-google-ads/source_google_ads/utils.py index 53c03616dd10..7c012ece757c 100644 --- a/airbyte-integrations/connectors/source-google-ads/source_google_ads/utils.py +++ b/airbyte-integrations/connectors/source-google-ads/source_google_ads/utils.py @@ -42,12 +42,12 @@ class GAQL: def parse(cls, query): m = cls.REGEX.match(query) if not m: - raise Exception(f"incorrect GAQL query statement: {repr(query)}") + raise ValueError(f"incorrect GAQL query statement: {repr(query)}") fields = [f.strip() for f in m.group("FieldNames").split(",")] for field in fields: if not cls.REGEX_FIELD_NAME.match(field): - raise Exception(f"incorrect GAQL query statement: {repr(query)}") + raise ValueError(f"incorrect GAQL query statement: {repr(query)}") resource_name = m.group("ResourceName") where = cls._normalize(m.group("WhereClause") or "")