-
1. Re: pages.xml adding <action> or <raise-event> in <exception> block
christian.bauer Mar 6, 2008 3:10 PM (in response to gonzalad)Absolutely not, the system is in an unknown state after an exception and there is no way that you could guarantee anything at that point.
-
2. Re: pages.xml adding <action> or <raise-event> in <exception> block
keithnaas Mar 6, 2008 3:18 PM (in response to gonzalad)Sounds like a great phrase to add to the seam docs
When an exception is handled, the only thing you can guarantee is that the system is in an unknown state
:)
-
3. Re: pages.xml adding <action> or <raise-event> in <exception> block
gonzalad Mar 6, 2008 4:05 PM (in response to gonzalad)Thanks for the answer.
I was just wondering if I want to trace the erreur myself (like storing a record in the database whenever this error happens), how could I do this without this kind of feature ?
I don't have this need right now, was asking for curiosity.
Thanks once more !
-
4. Re: pages.xml adding <action> or <raise-event> in <exception> block
christian.bauer Mar 6, 2008 4:22 PM (in response to gonzalad)Well, the answer is You do not store it in a database. What if the exception was
database is down
? The whole point of a RuntimeException (and that is what we are talking about here) is that your thread of execution is dead if it occurs.Write a custom LogAppender for Log4j or something.
-
5. Re: pages.xml adding <action> or <raise-event> in <exception> block
cpopetz Mar 9, 2008 4:57 PM (in response to gonzalad)
Gonzalez Adrian wrote on Mar 06, 2008 04:05 PM:
Thanks for the answer.
I was just wondering if I want to trace the erreur myself (like storing a record in the database whenever this error happens), how could I do this without this kind of feature ?
I don't have this need right now, was asking for curiosity.
Thanks once more !While I agree with Christian's warnings about the system being in a bad state at the time an exception is unhandled, we successfully log all unhandled exceptions to a db, but we use a separate database/data source/ entityManager to ensure that it's mainly independent of whatever happened in the main conversation.
But, unfortunately, there's no clean way to execute an action on the global case of an unhandled error, so we do the following:
import org.jboss.seam.exception.Exceptions; @Scope(ScopeType.APPLICATION) @Name("org.jboss.seam.exception.exceptions") public class MyErrorHandler extends Exceptions { @Create public void initialize() throws Exception { super.initialize(); } public void handle (Exception e) throws Exception { try { super.handle(e); return; } catch (Exception rethrown) { //do our custom error handling here } }