File tree Expand file tree Collapse file tree 2 files changed +4
-1
lines changed Expand file tree Collapse file tree 2 files changed +4
-1
lines changed Original file line number Diff line number Diff line change 14
14
# See the License for the specific language governing permissions and
15
15
# limitations under the License.
16
16
from typing import Optional
17
+ from http import HTTPStatus
17
18
from requests import Response
18
19
19
20
@@ -66,6 +67,8 @@ def _get_error_message(response: Response):
66
67
error_message = error_json ['errorMessage' ]
67
68
elif response .status_code == 401 :
68
69
error_message = 'Unauthorized: Access is denied due to invalid credentials'
70
+ else :
71
+ error_message = HTTPStatus (response .status_code ).phrase
69
72
return error_message
70
73
except :
71
74
return response .text or error_message
Original file line number Diff line number Diff line change @@ -48,7 +48,7 @@ def test_api_exception():
48
48
content_type = 'application/json' )
49
49
mock_response = requests .get ('https://test-msg.com' )
50
50
exception = ApiException (500 , http_response = mock_response )
51
- assert exception .message == 'Unknown error '
51
+ assert exception .message == 'Internal Server Error '
52
52
53
53
responses .add (responses .GET ,
54
54
'https://test-errormessage.com' ,
You can’t perform that action at this time.
0 commit comments