Skip to content

Commit 57972e5

Browse files
committed
rimport: Improve handling of ValueError.
1 parent a41eb75 commit 57972e5

1 file changed

Lines changed: 5 additions & 6 deletions

File tree

rimport

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -102,15 +102,14 @@ def stage_data(src: Path, inputdata_root: Path, staging_root: Path) -> None:
102102

103103
try:
104104
rel = src.resolve().relative_to(inputdata_root.resolve())
105-
except ValueError:
105+
except ValueError as exc:
106106
if src.resolve().is_relative_to(staging_root.resolve()):
107107
raise RuntimeError(
108108
f"Source file '{src.name}' is already under staging directory '{staging_root}'."
109-
)
110-
else:
111-
raise RuntimeError(
112-
f"source not under inputdata root: {src} not in {inputdata_root}"
113-
)
109+
) from exc
110+
raise RuntimeError(
111+
f"source not under inputdata root: {src} not in {inputdata_root}"
112+
) from exc
114113

115114
dst = staging_root / rel
116115
dst.parent.mkdir(parents=True, exist_ok=True)

0 commit comments

Comments
 (0)