Skip to content

Commit 6edcd58

Browse files
author
Michele Simionato
committed
Improved error message for missing job
1 parent fab795b commit 6edcd58

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

openquake/commonlib/datastore.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
import h5py
2626

2727
from openquake.baselib import hdf5, performance, general
28+
from openquake.commonlib import dbapi
2829
from openquake.commonlib.logs import get_datadir, CALC_REGEX, dbcmd, init
2930

3031

@@ -61,6 +62,8 @@ def _read(calc_id, datadir, mode, haz_id=None):
6162
if isinstance(calc_id, int):
6263
# look in the db
6364
job = dbcmd('get_job', calc_id)
65+
if job is None:
66+
raise dbapi.NotFound(f'{calc_id=} missing in the database')
6467
path = job.ds_calc_dir + '.hdf5'
6568
hc_id = job.hazard_calculation_id
6669
if not hc_id and haz_id:

0 commit comments

Comments
 (0)