34
Exception handling
In ePOS-Print SDK for Android, it is designed that when an error occurs, a propriety exception with an integer
(int) type parameter is generated to notify the calling side of such an error. The ePOS-Print API acquires
information using the EposException class (p.40), and the search API acquires information using the
EposException class (p.40). The following errors are sent:
Steps for Handling
ePOS-Print API
Acquire the error status using getErrorStatus (p.93) of the EposException class, and acquire the printer status
using getPrinterStatus (p.94) of that class. Use the programming example below for your reference.
Type Description
Error status
Cause of error when each class's API was executed.
For details, refer to Error Status List (p.36).
Printer status
Status of the printer when print data was sent.
The printer status can be acquired only when sendData (p.91) is
executed.
For details, refer to Printer Status List (p.37).
//<Send data for confirmation>
Print printer = new Print();
int[] status = new int[1];
status[0] = 0;
try {
//Create a print document
Builder builder = new Builder("TM-T88V", Builder.MODEL_ANK);
builder.addText("Hello,\t");
builder.addText("World!\n");
builder.addCut(Builder.CUT_FEED);
//<Send print data>
printer.openPrinter(Print.DEVTYPE_TCP, "192.168.192.168");
printer.sendData(builder, 10000, status);
printer.closePrinter();
} catch (EposException e) {
//Acquire the error status
int errStatus = e.getErrorStatus();
//Acquire the printer status
status[0] = e.getPrinterStatus();
printer.closePrinter();
}