Skip to content
This repository was archived by the owner on May 7, 2026. It is now read-only.

Commit 1373c6f

Browse files
committed
include filename/path details in exception messages
1 parent 06ce16c commit 1373c6f

1 file changed

Lines changed: 6 additions & 6 deletions

File tree

zxing/__init__.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -45,22 +45,22 @@ def decode(self, filename, try_harder=False, possible_formats=None):
4545
try:
4646
p = sp.Popen(cmd, stdout=sp.PIPE, stderr=sp.STDOUT, universal_newlines=False)
4747
except FileNotFoundError as e:
48-
raise BarCodeReaderException("Java binary specified does not exist", self.java, e)
48+
raise BarCodeReaderException("Java binary specified (%s) does not exist" % self.java, self.java, e)
4949
except PermissionError as e:
50-
raise BarCodeReaderException("Java binary specified is not executable", self.java, e)
51-
stdout, _ = p.communicate()
50+
raise BarCodeReaderException("Java binary specified (%s) is not executable" % self.java, self.java, e)
51+
stdout, stderr = p.communicate()
5252

5353
if stdout.startswith((b'Error: Could not find or load main class com.google.zxing.client.j2se.CommandLineRunner',
5454
b'Exception in thread "main" java.lang.NoClassDefFoundError:')):
55-
raise BarCodeReaderException("Java JARs not found in expected directory", self.classpath)
55+
raise BarCodeReaderException("Java JARs not found in classpath (%s)" % self.classpath, self.classpath)
5656
elif stdout.startswith(b'''Exception in thread "main" javax.imageio.IIOException: Can't get input stream from URL!'''):
57-
raise BarCodeReaderException("Could not find image path", filename)
57+
raise BarCodeReaderException("Could not find image path: %s" % filename, filename)
5858
elif stdout.startswith(b'''Exception in thread "main" java.io.IOException: Could not load '''):
5959
raise BarCodeReaderException("Java library could not read image; is it in a supported format?", filename)
6060
elif stdout.startswith(b'''Exception '''):
6161
raise BarCodeReaderException("Unknown Java exception: %s" % stdout)
6262
elif p.returncode:
63-
raise BarCodeReaderException("Unexpected subprocess return code %d" % p.returncode, self.java)
63+
raise BarCodeReaderException("Unexpected Java subprocess return code %d" % p.returncode, self.java)
6464

6565
return BarCode.parse(stdout)
6666

0 commit comments

Comments
 (0)