1
I have this asynchronous method:
async printForNetwork( device ) {
try {
const options = {encoding: "860"};
const printer = new Printer(device, options);
device.open( err => {
if (err)
return err; // preciso lançar a exception desse erro
printer.align('CT');
printer.size(1, 2);
printer.text('Teste');
printer.close();
});
} catch (e) {
throw e;
}
}
I need to make an exception if the attribute err
in device.open
to treat it in catch
.
but if I make a throw
inside device.open
the exception is not being captured.
Rafael, you cannot throw and treat the exception when consuming the method, consuming with then/catch?
– Daniel Mendes
That one
try catch
it has no sense, if you will just throw the exception, without any treatment, do not need it– Costamilam