From 21e853c1f21d3b4c3c97a403fe4456ae2aa7e63a Mon Sep 17 00:00:00 2001 From: Dmitriy Smirnov Date: Fri, 22 Mar 2024 18:42:44 +0300 Subject: [PATCH] Add response text to error msg of decort_api_call method --- module_utils/decort_utils.py | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/module_utils/decort_utils.py b/module_utils/decort_utils.py index 70c2765..f6c3499 100644 --- a/module_utils/decort_utils.py +++ b/module_utils/decort_utils.py @@ -392,10 +392,11 @@ class DecortController(object): retry_counter = retry_counter - 1 else: self.result['failed'] = True - self.result['msg'] = ("Error when calling DECORT API '{}', HTTP status code '{}', " - "reason '{}', parameters '{}'.").format(api_resp.url, - api_resp.status_code, - api_resp.reason, arg_params) + self.result['msg'] =\ + (f'Error when calling DECORT API {api_resp.url}' + f', HTTP status code {api_resp.status_code}' + f', reason "{api_resp.reason}"' + f', parameters {arg_params}, text {api_resp.text}.') self.amodule.fail_json(**self.result) return None # actually, this directive will never be executed as fail_json aborts the script