Exceptions
Module escpos.exceptions
ESC/POS Exceptions classes.
Result/Exit codes:
0 = success
10 = No Barcode type defined
BarcodeTypeError20 = Barcode size values are out of range
BarcodeSizeError30 = Barcode text not supplied
BarcodeCodeError40 = Image height is too large
ImageSizeError41 = Image width is too large
ImageWidthError50 = No string supplied to be printed
TextError60 = Invalid pin to send Cash Drawer pulse
CashDrawerError70 = Invalid number of tab positions
TabPosError80 = Invalid char code
CharCodeError90 = Device not found
DeviceNotFoundError91 = USB device not found
USBNotFoundError100 = Set variable out of range
SetVariableError200 = Configuration not found
ConfigNotFoundError210 = Configuration syntax error
ConfigSyntaxError220 = Configuration section not found
ConfigSectionMissingError
- author:
python-escpos developers
- organization:
Bashlinux and python-escpos
- copyright:
Copyright (c) 2012-2017 Bashlinux and python-escpos
- license:
MIT
- exception escpos.exceptions.Error(msg, status=None)[source]
Bases:
ExceptionBase class for ESC/POS errors.
inheritance:

- add_note()
Exception.add_note(note) – add a note to the exception
- with_traceback()
Exception.with_traceback(tb) – set self.__traceback__ to tb and return self.
- exception escpos.exceptions.BarcodeTypeError(msg='')[source]
Bases:
ErrorNo Barcode type defined.
This exception indicates that no known barcode-type has been entered. The barcode-type has to be one of those specified in
escpos.escpos.Escpos.barcode(). The returned error code is 10.inheritance:

- add_note()
Exception.add_note(note) – add a note to the exception
- with_traceback()
Exception.with_traceback(tb) – set self.__traceback__ to tb and return self.
- exception escpos.exceptions.BarcodeSizeError(msg='')[source]
Bases:
ErrorBarcode size is out of range.
This exception indicates that the values for the barcode size are out of range. The size of the barcode has to be in the range that is specified in
escpos.escpos.Escpos.barcode(). The resulting return code is 20.inheritance:

- add_note()
Exception.add_note(note) – add a note to the exception
- with_traceback()
Exception.with_traceback(tb) – set self.__traceback__ to tb and return self.
- exception escpos.exceptions.BarcodeCodeError(msg='')[source]
Bases:
ErrorNo Barcode code was supplied, or it is incorrect.
No data for the barcode has been supplied in
escpos.escpos.Escpos.barcode()or the the check parameter was True and the check failed. The return code for this exception is 30.inheritance:

- add_note()
Exception.add_note(note) – add a note to the exception
- with_traceback()
Exception.with_traceback(tb) – set self.__traceback__ to tb and return self.
- exception escpos.exceptions.ImageSizeError(msg='')[source]
Bases:
ErrorImage height is longer than 255px and can’t be printed.
The return code for this exception is 40.
inheritance:

- add_note()
Exception.add_note(note) – add a note to the exception
- with_traceback()
Exception.with_traceback(tb) – set self.__traceback__ to tb and return self.
- exception escpos.exceptions.ImageWidthError(msg='')[source]
Bases:
ErrorImage width is too large.
The return code for this exception is 41.
inheritance:

- add_note()
Exception.add_note(note) – add a note to the exception
- with_traceback()
Exception.with_traceback(tb) – set self.__traceback__ to tb and return self.
- exception escpos.exceptions.TextError(msg='')[source]
Bases:
ErrorText string must be supplied to the text() method.
This exception is raised when an empty string is passed to
escpos.escpos.Escpos.text(). The return code for this exception is 50.inheritance:

- add_note()
Exception.add_note(note) – add a note to the exception
- with_traceback()
Exception.with_traceback(tb) – set self.__traceback__ to tb and return self.
- exception escpos.exceptions.CashDrawerError(msg='')[source]
Bases:
ErrorValid pin must be set in order to send pulse.
A valid pin number has to be passed onto the method
escpos.escpos.Escpos.cashdraw(). The return code for this exception is 60.inheritance:

- add_note()
Exception.add_note(note) – add a note to the exception
- with_traceback()
Exception.with_traceback(tb) – set self.__traceback__ to tb and return self.
- exception escpos.exceptions.TabPosError(msg='')[source]
Bases:
ErrorTab position is invalid.
Valid tab positions must be set by using from 1 to 32 tabs, and between 1 and 255 tab size values. Both values multiplied must not exceed 255, since it is the maximum tab value.
This exception is raised by
escpos.escpos.Escpos.control(). The return code for this exception is 70.inheritance:

- add_note()
Exception.add_note(note) – add a note to the exception
- with_traceback()
Exception.with_traceback(tb) – set self.__traceback__ to tb and return self.
- exception escpos.exceptions.CharCodeError(msg='')[source]
Bases:
ErrorValid char code must be set.
The supplied charcode-name in
escpos.escpos.Escpos.charcode()is unknown. The return code for this exception is 80.inheritance:

- add_note()
Exception.add_note(note) – add a note to the exception
- with_traceback()
Exception.with_traceback(tb) – set self.__traceback__ to tb and return self.
- exception escpos.exceptions.DeviceNotFoundError(msg='')[source]
Bases:
ErrorDevice was not found.
The device seems to be not accessible. The return code for this exception is 90.
inheritance:

- add_note()
Exception.add_note(note) – add a note to the exception
- with_traceback()
Exception.with_traceback(tb) – set self.__traceback__ to tb and return self.
- exception escpos.exceptions.USBNotFoundError(msg='')[source]
Bases:
DeviceNotFoundErrorUSB device was not found (probably not plugged in).
The USB device seems to be not plugged in. The return code for this exception is 91.
inheritance:

- add_note()
Exception.add_note(note) – add a note to the exception
- with_traceback()
Exception.with_traceback(tb) – set self.__traceback__ to tb and return self.
- exception escpos.exceptions.SetVariableError(msg='')[source]
Bases:
ErrorA set method variable was out of range.
Check set variables against minimum and maximum values The return code for this exception is 100.
inheritance:

- add_note()
Exception.add_note(note) – add a note to the exception
- with_traceback()
Exception.with_traceback(tb) – set self.__traceback__ to tb and return self.
- exception escpos.exceptions.ConfigNotFoundError(msg='')[source]
Bases:
ErrorThe configuration file was not found.
The default or passed configuration file could not be read The return code for this exception is 200.
inheritance:

- add_note()
Exception.add_note(note) – add a note to the exception
- with_traceback()
Exception.with_traceback(tb) – set self.__traceback__ to tb and return self.
- exception escpos.exceptions.ConfigSyntaxError(msg='')[source]
Bases:
ErrorThe configuration file is invalid.
The syntax is incorrect The return code for this exception is 210.
inheritance:

- add_note()
Exception.add_note(note) – add a note to the exception
- with_traceback()
Exception.with_traceback(tb) – set self.__traceback__ to tb and return self.
- exception escpos.exceptions.ConfigSectionMissingError(msg='')[source]
Bases:
ErrorThe configuration file is missing a section.
The part of the config asked for does not exist in the loaded configuration The return code for this exception is 220.
inheritance:

- add_note()
Exception.add_note(note) – add a note to the exception
- with_traceback()
Exception.with_traceback(tb) – set self.__traceback__ to tb and return self.