node-printer icon indicating copy to clipboard operation
node-printer copied to clipboard

Wrong error message is shown when printer name is incorrect.

Open dharijanto opened this issue 7 years ago • 1 comments

printer.printFile({filename:filename,
    printer: "EPSON_L220_Series", // printer name, if missing then will print to default printer
    success:function(jobID){
      console.log("sent to printer with ID: "+jobID);
    },
    error:function(err){
      console.log(err);
    }
  });

When a wrong printer name is passed into the 'printer' argument in the snippet above, the error message printed is "Error: No such file or directory".

I'll try to spare some time to make a fix for this.

Thanks in advance for this library! :)

dharijanto avatar Dec 14 '18 05:12 dharijanto

After reading through the C++ code, turns out that the error message comes from CUPS library itself..

   int job_id = cupsPrintFile(*printer, *filename, *docname, options.getNumOptions(), options.get());
    if(job_id == 0){
        MY_NODE_MODULE_RETURN_VALUE(V8_STRING_NEW_UTF8(cupsLastErrorString()));
    } else {
        MY_NODE_MODULE_RETURN_VALUE(V8_VALUE_NEW(Number, job_id));
    }

cupsLastErrorString() function is the culprit... Maybe this issue is fixed on the latest version of CUPS, though. I should check..

dharijanto avatar Dec 14 '18 05:12 dharijanto