22from datetime import datetime
33from enum import Enum , StrEnum
44from functools import cache
5+ from json import dumps as json_dumps
56import logging
67import os
78from typing import (
@@ -98,6 +99,13 @@ def retry_on_rate_limit(func):
9899def jira_api_get (path : str , * , params : dict | None = None ) -> Any :
99100 url = f"{ jira_url ()} /rest/api/2/{ path } "
100101 response = requests_session ().get (url , headers = jira_headers (), params = params )
102+ if not response .ok :
103+ logger .error (
104+ "GET %s%s failed.\n error:\n %s" ,
105+ url ,
106+ f" (params={ params } )" if params else "" ,
107+ response .text ,
108+ )
101109 raise_for_status (response )
102110 return response .json ()
103111
@@ -120,6 +128,13 @@ def jira_api_post(
120128) -> Any | None :
121129 url = f"{ jira_url ()} /rest/api/2/{ path } "
122130 response = requests_session ().post (url , headers = jira_headers (), json = json )
131+ if not response .ok :
132+ logger .error (
133+ "POST to %s failed\n body:\n %s\n error:\n %s" ,
134+ url ,
135+ json_dumps (json , indent = 2 ),
136+ response .text ,
137+ )
123138 raise_for_status (response )
124139 if decode_response :
125140 return response .json ()
@@ -143,6 +158,13 @@ def jira_api_put(
143158) -> Any | None :
144159 url = f"{ jira_url ()} /rest/api/2/{ path } "
145160 response = requests_session ().put (url , headers = jira_headers (), json = json )
161+ if not response .ok :
162+ logger .error (
163+ "PUT to %s failed\n body:\n %s\n error:\n %s" ,
164+ url ,
165+ json_dumps (json , indent = 2 ),
166+ response .text ,
167+ )
146168 raise_for_status (response )
147169 if decode_response :
148170 return response .json ()
0 commit comments