You are viewing a plain text version of this content. The canonical link for it is here.
Posted to batik-users@xmlgraphics.apache.org by Kevin Whittington <Ke...@catalinamarketing.com> on 2005/10/25 21:07:37 UTC

PrintTranscoder - Incorrect Exception Handling

I just noticed that the PrintTranscoder that inherits from the
SVGAbstractTranscoder does not throw a TranscoderException as the
ImageTranscoders do.  The JavaDoc states that it does throw the
TranscoderException however the code does not.  This appears to be a
bug.

In my application (which led me to discover this problem), I transcode
an SVG document and call the print() method from a PrintTranscoder.  If
the SVG document being transcoded has an unrecognizable tag, the
transcoder internally throws an exception but no exception is passed up
to the public transcode() method.  Therefore, my calling code is
completely unaware that the document has not printed due to the error.

Is this the intended behavior of the PrintTranscoder class?

Kevin Whittington
Catalina Marketing Corporation

Re: PrintTranscoder - Incorrect Exception Handling

Posted by th...@kodak.com.
Hi Kevin,

"Kevin Whittington" <Ke...@catalinamarketing.com> wrote on 
10/25/2005 03:07:37 PM:

> I just noticed that the PrintTranscoder that inherits from the 
> SVGAbstractTranscoder does not throw a TranscoderException as the 
> ImageTranscoders do.  The JavaDoc states that it does throw the 
> TranscoderException however the code does not. 

   The problem is that the PrintTranscoder is a bit different
from the other transcoders in that the 'transcode' method doesn't
actually transcode anything, it simply collects URL's for later
printing as one potentially multi-page document.

> This appears to be a bug. In my application (which led me to 
> discover this problem), I transcode an SVG document and call 
> the print() method from a PrintTranscoder.  If the SVG 
> document being transcoded has an unrecognizable tag, the 
> transcoder internally throws an exception but no exception 
> is passed up to the public transcode() method. 

   This is because by the time the exception is generated
the 'transcode' method has long since exited.  The Print
transcoder doesn't look at the content until you call print.

> Therefore, my calling code is completely unaware that the document 
> has not printed due to the error.
> Is this the intended behavior of the PrintTranscoder class? 

   Yes, and no, there is no good way for the PrintTranscoder to
throw an error during the call to 'transcode'.  It is theoretically
possible for it to throw an error in response to 'print()' although
not easy since the actual error is detected in the 'Printable.print'
method which can't throw an error, so it would have to 'ferret it away'
until it get's back into the 'PrintTranscoder.print' method at which
point it could re-wrap it as a PrinterException.

   However we don't do that.  Instead you should provide 
an implementation of an ErrorHandler to the Transcoder in
which case you will be called when the parse of the SVG file
fails (or just about anything else goes wrong).


---------------------------------------------------------------------
To unsubscribe, e-mail: batik-users-unsubscribe@xmlgraphics.apache.org
For additional commands, e-mail: batik-users-help@xmlgraphics.apache.org