Skip to content

Commit

Permalink
fix error handling in query
Browse files Browse the repository at this point in the history
  • Loading branch information
Roy Wiggins authored and Roy Wiggins committed Nov 5, 2024
1 parent 2abb6e5 commit 1090bb3
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
2 changes: 1 addition & 1 deletion tests/test_query.py
Original file line number Diff line number Diff line change
Expand Up @@ -206,7 +206,7 @@ def test_query_job(dicom_server, tempdir, rq_connection,fs):
try:
example_dcm = next(k for k in Path(tempdir).rglob("*.dcm"))
except StopIteration:
assert False, f"No DICOM file found in {tempdir}"
raise Exception(f"No DICOM file found in {tempdir}")
assert pydicom.dcmread(example_dcm).AccessionNumber == MOCK_ACCESSIONS[0]

def tree(path, prefix='', level=0) -> None:
Expand Down
5 changes: 4 additions & 1 deletion webinterface/dashboards/query/jobs.py
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,10 @@ def execute(self, *, accessions: List[str], node: Union[DicomTarget, DicomWebTar
self._job.meta['failed_reason'] = str(e)
self._job.save_meta() # type: ignore
if self.parent and (job_parent := Job.fetch(self.parent)):
job_parent.meta['failed_reason'] = e.args[0]
if e.args:
job_parent.meta['failed_reason'] = f"{str(e)} ({str(e.args[0])})"
else:
job_parent.meta['failed_reason'] = str(e)
job_parent.save_meta() # type: ignore
Queue(job_parent.origin)._enqueue_job(job_parent,at_front=True)
raise
Expand Down

0 comments on commit 1090bb3

Please sign in to comment.