qzind / qz-print

Archive for legacy qz-print versions (1.8, 1.9). See https://github.com/qzind/tray for modern versions.
Other
141 stars 101 forks source link

clearException() method not working as expected #103

Closed tresf closed 8 years ago

tresf commented 8 years ago

Quoting the original bug report which came in via email:

In the qzDonePrinting method if there is an exception it alerts the exception and then calls clearException(). The first time there is a printing exception the alert reports correctly but it appears that the exception is NOT cleared. If you successfully print again the print works fine with no errors but the getException() method still returns a valid object but getLocalizedMessage() returns null.

The offending code appears to be here:

https://github.com/qzind/qz-print/blob/1.9/js/qz-websocket.js#L189:L197

tresf commented 8 years ago

@bberenz I spent a couple hours on this and I'm in a tailspin trying to figure out why getException never gets cleared.

Can you take a look? This is a core function that seems to have been broken since the release of QZ Tray.

akberenz commented 8 years ago

I think your confusion came from the weird way we are handling exceptions in 1.9, because we always send a result when the exception value changes, even on null, and re-purpose it to be a property on a js object. https://github.com/qzind/qz-print/blob/1.9/src/qz/ws/PrintSocket.java#L352

tresf commented 8 years ago

@bberenz Thanks that was my first instinct, but now when you try to print an XPS document and "Cancel" at the "Save As" screen, it doesn't fire an exception because getLocalizedMessage is null. Shall we also add in an:

// pseudocode
if (qz.getException().getLocalizedMessage() == null) {
   eMsg = qz.getException().getClass().getName(); // or perhaps "Unknown Error"
}
akberenz commented 8 years ago

Yes, we should. I've added it under 9a9fa61190db52d4938b0ab8651faa63ef24436c.

tresf commented 8 years ago

:+1:

image