diff --git a/imod/formats/prj/prj.py b/imod/formats/prj/prj.py index dd9859a92..726f942b8 100644 --- a/imod/formats/prj/prj.py +++ b/imod/formats/prj/prj.py @@ -451,6 +451,8 @@ def _parse_block(lines: _LineIterator, content: Dict[str, Any]) -> None: while key is None and not lines.finished: n, key, active = _parse_blockheader(lines) + if key is None: + return try: if key in KEYS: if n != 1: @@ -482,7 +484,9 @@ def _parse_block(lines: _LineIterator, content: Dict[str, Any]) -> None: ) except Exception as e: - raise type(e)(f"{e}\nError occurred for keyword: {key}") + raise type(e)( + f"{e}\nError occurred for keyword: {key} in line {lines.count + 1}" + ) if blockcontent is not None and active is not None: blockcontent["active"] = active diff --git a/imod/tests/test_formats/test_prj.py b/imod/tests/test_formats/test_prj.py index b5d07f419..9d79382e5 100644 --- a/imod/tests/test_formats/test_prj.py +++ b/imod/tests/test_formats/test_prj.py @@ -94,6 +94,8 @@ 1,2, 000, 100000.0, 1.0, -999.9900 ,"{basepath}/first.gen" 1,2, 000, 100000.0, 1.0, -999.9900 ,"{basepath}/second.gen" + + 0001,(PCG),1, Precondition Conjugate-Gradient,[] MXITER= 500 ITER1= 25 @@ -118,6 +120,7 @@ "benzene",1 "chloride",2 + """ )