diff --git a/src/ert/job_queue/realization_state.py b/src/ert/job_queue/realization_state.py index 23e3b2ef5d7..76dd0a53a65 100644 --- a/src/ert/job_queue/realization_state.py +++ b/src/ert/job_queue/realization_state.py @@ -140,11 +140,19 @@ def on_enter_EXIT(self) -> None: ) if exit_file_path.exists(): exit_file = etree.parse(exit_file_path) - failed_job = exit_file.find("job").text - error_reason = exit_file.find("reason").text - stderr_capture = exit_file.find("stderr").text + failed_job: Optional[str] = None + if job_elem := exit_file.find("job"): + failed_job = job_elem.text - stderr_file = "" + error_reason: Optional[str] = None + if reason_elem := exit_file.find("reason"): + error_reason = reason_elem.text + + stderr_capture: Optional[str] = None + if stderr_elem := exit_file.find("stderr"): + stderr_capture = stderr_elem.text + + stderr_file: Optional[str] = None if stderr_file_node := exit_file.find("stderr_file"): stderr_file = stderr_file_node.text