Skip to content

Commit 9fc0d97

Browse files
authored
Update code to share exception types UnicodeDecodeError, JSONDecodeError, TypeError, KeyError (#1560)
* update code to share exception type Signed-off-by: ddimatos <[email protected]> * Add changelog fragment Signed-off-by: ddimatos <[email protected]> * Fix pyflakes unused variable Signed-off-by: ddimatos <[email protected]> --------- Signed-off-by: ddimatos <[email protected]>
1 parent 7b6becb commit 9fc0d97

File tree

2 files changed

+9
-3
lines changed

2 files changed

+9
-3
lines changed
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
bugfixes:
2+
- zos_job_submit - Was not propagating any error types UnicodeDecodeError,
3+
JSONDecodeError, TypeError, KeyError when encountered, now the error
4+
message shares the type error.
5+
(https://github.com/ansible-collections/ibm_zos_core/pull/1560).

plugins/module_utils/job.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -463,10 +463,11 @@ def _get_job_status(job_id="*", owner="*", job_name="*", dd_name=None, dd_scan=T
463463
single_dd["step_name"],
464464
single_dd["dd_name"]
465465
)
466-
except (UnicodeDecodeError, JSONDecodeError, TypeError, KeyError):
466+
except (UnicodeDecodeError, JSONDecodeError, TypeError, KeyError) as e:
467+
error_type = e.__class__.__name__
467468
tmpcont = (
468-
"Non-printable UTF-8 characters were present in this output. "
469-
"Please access it from the job log."
469+
f"Non-printable UTF-8 characters were present in this output, a {error_type} error has occurred."
470+
"Please access the content from the job log."
470471
)
471472

472473
dd["content"] = tmpcont.split("\n")

0 commit comments

Comments
 (0)