Mdu
Mdu

Reputation: 21

Epson SDK not giving error codes when unable to connect to printer, I'm using Angular Nativescript

Is there a way of getting error codes from printer.connect using epson ePOS SDK? All I'm getting is "Error: com.epson.epos2.Epos2Exception", with no apparent way of investigating the error further. Below is the code to connect to the printer, printer initialization works fine, the issue is when attempting to connect.

Initialise printer

 initializePrinter() {
        try {
          // Replace `TM_T20` with your specific printer model and `MODEL_ANK` with language
          this.printer = new com.epson.epos2.printer.Printer(
            com.epson.epos2.printer.Printer.TM_T88, // Adjust to your model
            com.epson.epos2.printer.Printer.MODEL_ANK,
            null
          );
          console.log('Printer initialized');
          this.showAlert('Printer initialized')
         
            this.connecttoPrinter();
            } catch (error) {
            console.error("Error initializing printer:", error);
            this.showAlert('Error initializing printer')
            }
      }

Connect to printer

  connecttoPrinter() {
        try {
             this.printer.connect("TCP:192.168.0.115", this.printer.PARAM_DEFAULT);
            console.log('Connected to printer');
            this.showAlert('Connected to printer')
            this.printSampleText();
            }
            catch (error) {
                if (error instanceof com.epson.epos2.Epos2Exception) {
                    console.error("Epos Error connecting to printer:", error.getErrorStatus());
                    this.showAlert('Epos Error connecting to printer '+ error.getErrorStatus())
                }else{
                    console.log("Error connecting to printer:="+ error);
                    this.showAlert('Error connecting to printer '+ error);
                   
                }
            }
      }

Upvotes: 0

Views: 40

Answers (0)

Related Questions