From ee99a00b15659777fb00998b137ff121b7fa21d5 Mon Sep 17 00:00:00 2001 From: "zongsi.zhang" Date: Thu, 12 Sep 2024 15:41:11 +0800 Subject: [PATCH] feat: When rest api raise http error, print the resp content (#16) --- airflow_providers_wherobots/hooks/rest_api.py | 5 ++++- pyproject.toml | 2 +- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/airflow_providers_wherobots/hooks/rest_api.py b/airflow_providers_wherobots/hooks/rest_api.py index 30ab6e4..8081545 100644 --- a/airflow_providers_wherobots/hooks/rest_api.py +++ b/airflow_providers_wherobots/hooks/rest_api.py @@ -73,7 +73,10 @@ def _api_call( resp = self.session.request( url=url, method=method, json=payload, auth=auth, params=params ) - resp.raise_for_status() + try: + resp.raise_for_status() + except requests.HTTPError as e: + raise RuntimeError(f"HTTP error: {e} with response: {resp.text}") from e return resp def get_run(self, run_id: str) -> Run: diff --git a/pyproject.toml b/pyproject.toml index b225beb..805c89d 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,6 +1,6 @@ [tool.poetry] name = "airflow-providers-wherobots" -version = "0.1.12" +version = "0.1.13" description = "Airflow extension for communicating with Wherobots Cloud" authors = ["zongsi.zhang "] readme = "README.md"