Make BarcodeSizeError and BarcodeTypeError display the erroneous value

(MUCH more helpful for debugging)
This commit is contained in:
Stephan Sokolow 2014-05-22 00:47:08 -04:00 committed by Patrick Kanzler
parent f7a2caee72
commit e988873999
2 changed files with 5 additions and 5 deletions

View File

@ -309,12 +309,12 @@ class Escpos(object):
if 1 <= height <= 255: if 1 <= height <= 255:
self._raw(BARCODE_HEIGHT + chr(height)) self._raw(BARCODE_HEIGHT + chr(height))
else: else:
raise BarcodeSizeError() raise BarcodeSizeError("height = %s" % height)
# Width # Width
if 2 <= width <= 6: if 2 <= width <= 6:
self._raw(BARCODE_WIDTH + chr(width)) self._raw(BARCODE_WIDTH + chr(width))
else: else:
raise BarcodeSizeError() raise BarcodeSizeError("width = %s" % width)
# Font # Font
if font.upper() == "B": if font.upper() == "B":
self._raw(BARCODE_FONT_B) self._raw(BARCODE_FONT_B)
@ -345,7 +345,7 @@ class Escpos(object):
elif bc.upper() == "NW7": elif bc.upper() == "NW7":
self._raw(BARCODE_NW7) self._raw(BARCODE_NW7)
else: else:
raise BarcodeTypeError() raise BarcodeTypeError(bc)
# Print Code # Print Code
if code: if code:
self._raw(code) self._raw(code)

View File

@ -45,7 +45,7 @@ class BarcodeTypeError(Error):
self.resultcode = 10 self.resultcode = 10
def __str__(self): def __str__(self):
return "No Barcode type is defined" return "No Barcode type is defined (%s)" % self.msg
class BarcodeSizeError(Error): class BarcodeSizeError(Error):
@ -61,7 +61,7 @@ class BarcodeSizeError(Error):
self.resultcode = 20 self.resultcode = 20
def __str__(self): def __str__(self):
return "Barcode size is out of range" return "Barcode size is out of range (%s)" % self.msg
class BarcodeCodeError(Error): class BarcodeCodeError(Error):