Re: exception on error

2004-10-25 Thread Chris Bowditch
Andreas L. Delmelle wrote:
From: Agar, Robert [mailto:[EMAIL PROTECTED]
>>
I have FOP running embedded in a java program. How do I make it
throw an exception on an error, rather than just logging it?
AFAICT no additional Exception is thrown, most likely because an image not
being found can hardly be considered a 'fatal' error --rendering can
continue, just leaving out the offending fo:external-graphic element-- and
the XSL-FO Rec prescribes nothing in particular for dealing with an invalid
'src' attribute, but it seems feasible enough to modify the code so that
when the MalformedURLException or FopImageException is caught, it throws a
FOPException --which, IIUC, should be enough to send the signal to break off
any further processing--, and when you catch that Exception in your app, you
can then provide the necessary error-handling code for it.
You dont need to modify the FOP code to catch this error. The best way to do 
it is to write a class that implements the 
org.apache.fop.messaging.MessageListener interface. The processMessage method 
can easily identify messages of type ERROR and throw an exception to halt the 
user's application.

Once youve written a class to handle messages you will need call:
MessageHandler.setScreenLogger(logger);
m_fopDriver.setLogger(logger);
Chris
-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]


RE: exception on error

2004-10-22 Thread Andreas L. Delmelle
> -Original Message-
> From: Agar, Robert [mailto:[EMAIL PROTECTED]
>

Hi,

> I have FOP running embedded in a java program. How do I make it
> throw an exception on an error, rather than just logging it?
>
> The particular error I want it to fail on is this:
> [ERROR] Error while creating area : Error with image URL:
> Images\test.jpeg (The system cannot find the path specified) and
> no base URL is specified
>

In maintenance (FOP 0.20.5), the stated error message appears in
org.apache.fop.fo.flow.ExternalGraphic.java (line: 296 and following --catch
MalformedURLException or FopImageException).

AFAICT no additional Exception is thrown, most likely because an image not
being found can hardly be considered a 'fatal' error --rendering can
continue, just leaving out the offending fo:external-graphic element-- and
the XSL-FO Rec prescribes nothing in particular for dealing with an invalid
'src' attribute, but it seems feasible enough to modify the code so that
when the MalformedURLException or FopImageException is caught, it throws a
FOPException --which, IIUC, should be enough to send the signal to break off
any further processing--, and when you catch that Exception in your app, you
can then provide the necessary error-handling code for it.


Greetz,

Andreas


-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]