Skip to content

Commit 4409ef3

Browse files
committed
jvm_version: handle CalledProcessError
The function is supposed to raise RuntimeError, not CalledProcessError, if the version cannot be determined. See also imagej/pyimagej#237.
1 parent 7528653 commit 4409ef3

1 file changed

Lines changed: 7 additions & 3 deletions

File tree

src/scyjava/_java.py

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -144,9 +144,13 @@ def jvm_version() -> str:
144144
if java is None:
145145
raise RuntimeError(f"No java executable found inside: {p}")
146146

147-
output = subprocess.check_output(
148-
[str(java), "-version"], stderr=subprocess.STDOUT
149-
).decode()
147+
try:
148+
output = subprocess.check_output(
149+
[str(java), "-version"], stderr=subprocess.STDOUT
150+
).decode()
151+
except subprocess.CalledProcessError as e:
152+
raise RuntimeError("System call to java failed") from e
153+
150154
m = re.match('.*version "(([0-9]+\\.)+[0-9]+)', output)
151155
if not m:
152156
raise RuntimeError(f"Inscrutable java command output:\n{output}")

0 commit comments

Comments
 (0)