@@ -47,11 +47,30 @@ def _read_with_journalctl(self, args: Optional[JournalCollectorArgs] = None):
4747 str|None: system journal read
4848 """
4949
50- if args is not None and args .boot :
51- boot_arg = f" -b { args .boot } "
52- self .CMD = f"journalctl --no-pager{ boot_arg } --system --output=short-iso"
50+ cmd = "journalctl --no-pager --system --output=short-iso"
51+ try :
52+ # safe check for args.boot
53+ if args is not None and getattr (args , "boot" , None ):
54+ cmd = f"journalctl --no-pager -b { args .boot } --system --output=short-iso"
5355
54- res = self ._run_sut_cmd (self .CMD , sudo = True , log_artifact = False , strip = False )
56+ res = self ._run_sut_cmd (cmd , sudo = True , log_artifact = False , strip = False )
57+
58+ except Exception as exc :
59+
60+ import traceback
61+
62+ tb = traceback .format_exc ()
63+ self ._log_event (
64+ category = EventCategory .OS ,
65+ description = "Exception while running journalctl" ,
66+ data = {"command" : cmd , "exception" : str (exc ), "traceback" : tb },
67+ priority = EventPriority .ERROR ,
68+ console_log = True ,
69+ )
70+ # set result to error and return None so upstream code can continue
71+ self .result .message = "Could not read journalctl data"
72+ self .result .status = ExecutionStatus .ERROR
73+ return None
5574
5675 if res .exit_code != 0 :
5776 self ._log_event (
0 commit comments