[rules-users] How to do Exception Handling???

Swindells, Thomas TSwindells at nds.com
Mon Apr 12 11:31:28 EDT 2010


I'm not convinced that converting a java exception to a process fault with the same name is a solid behaviour.
In java it is perfectly permissible and valid for a piece of code to change the exception it throws to a subclass of that exception (eg throw a FileNotFoundException instead of a generic IOException).  Any legacy code which catches the IOException will keep working perfectly (unless they are do something really stupid).  However drools would be doing something stupid, it would be matching based upon the exception name not type hierarchy and the flow would suddenly break when you no longer have the right fault handler matching the right exception name.

I'd suggest the more sensible and solid default action would be to create of a fault with a name UnhandledException (and the exception as a payload).
This could be extended later so that a map from exception type -> fault name could be produced using the same matching logic as catch blocks.

Thomas

> -----Original Message-----
> From: rules-users-bounces at lists.jboss.org [mailto:rules-users-
> bounces at lists.jboss.org] On Behalf Of tolitius
> Sent: 12 April 2010 16:19
> To: rules-users at lists.jboss.org
> Subject: Re: [rules-users] How to do Exception Handling???
>
>
>
> Kris Verlaenen wrote:
> >
> > It is trivial to simply create an AbstractWorkItemHandler that would
> > transform a Java exception to a process fault with the same name
> >
> > ...But if we build this into the framework, it will be more difficult to
> > change it if you don't
> > want this behaviour (and we try to keep the maximum flexibility possible).
> >
> > Kris
> >
>
> Seems like a perfectly solid default behaviour to me. Features like this one
> are usually done (changed only if needed) via configuration.
>
> "Convention Over Configuration" applies to Java frameworks as well :)
> /Anatoly



**************************************************************************************
This message is confidential and intended only for the addressee. If you have received this message in error, please immediately notify the postmaster at nds.com and delete it from your system as well as any copies. The content of e-mails as well as traffic data may be monitored by NDS for employment and security purposes. To protect the environment please do not print this e-mail unless necessary.

NDS Limited. Registered Office: One London Road, Staines, Middlesex, TW18 4EX, United Kingdom. A company registered in England and Wales. Registered no. 3080780. VAT no. GB 603 8808 40-00
**************************************************************************************

This message is confidential and intended only for the addressee. If you have received this message in error, please immediately notify the postmaster at nds.com and delete it from your system as well as any copies. The content of e-mails as well as traffic data may be monitored by NDS for employment and security purposes.
To protect the environment please do not print this e-mail unless necessary.

An NDS Group Limited company. www.nds.com




More information about the rules-users mailing list