[jboss-svn-commits] JBL Code SVN: r14590 - labs/jbossrules/trunk/drools-compiler/src/main/java/org/drools/rule/builder.

jboss-svn-commits at lists.jboss.org jboss-svn-commits at lists.jboss.org
Sun Aug 26 08:42:05 EDT 2007


Author: tirelli
Date: 2007-08-26 08:42:05 -0400 (Sun, 26 Aug 2007)
New Revision: 14590

Modified:
   labs/jbossrules/trunk/drools-compiler/src/main/java/org/drools/rule/builder/PatternBuilder.java
Log:
Improving error handling

Modified: labs/jbossrules/trunk/drools-compiler/src/main/java/org/drools/rule/builder/PatternBuilder.java
===================================================================
--- labs/jbossrules/trunk/drools-compiler/src/main/java/org/drools/rule/builder/PatternBuilder.java	2007-08-26 12:40:17 UTC (rev 14589)
+++ labs/jbossrules/trunk/drools-compiler/src/main/java/org/drools/rule/builder/PatternBuilder.java	2007-08-26 12:42:05 UTC (rev 14590)
@@ -225,7 +225,10 @@
                 container.addConstraint( or );
             }
         } else {
-            throw new UnsupportedOperationException( "This is a bug: unable to build constraint descriptor: " + constraint );
+            context.getErrors().add( new RuleError( context.getRule(),
+                                                    (BaseDescr) constraint,
+                                                    null,
+                                                    "This is a bug: unable to build constraint descriptor: '" + constraint + "' in rule '" + context.getRule().getName() + "'" ) );
         }
     }
 
@@ -312,8 +315,10 @@
             constraint = new ReturnValueConstraint( extractor,
                                                     (ReturnValueRestriction) restriction );
         } else {
-            throw new UnsupportedOperationException( "Unknown restriction type: " + restriction.getClass() );
-
+            context.getErrors().add( new RuleError( context.getRule(),
+                                                    fieldConstraintDescr,
+                                                    null,
+                                                    "This is a bug: Unkown restriction type '" + restriction.getClass() + "' for pattern '"+pattern.getObjectType().toString()+"' in rule '"+context.getRule().getName()+"'" ) );
         }
 
         if ( container == null ) {
@@ -391,14 +396,21 @@
             } else if ( top.getConnective() == RestrictionConnectiveDescr.OR ) {
                 composite = new OrCompositeRestriction( restrictions );
             } else {
-                throw new UnsupportedOperationException( "Impossible to create a composite restriction for connective: " + top.getConnective() );
+                context.getErrors().add( new RuleError( context.getRule(),
+                                                        fieldConstraintDescr,
+                                                        null,
+                                                        "This is a bug: Impossible to create a composite restriction for connective: " + top.getConnective()+ "' for field '"+ fieldConstraintDescr.getFieldName() +"' in the rule '" + context.getRule().getName() + "'" ) );
             }
 
             return composite;
         } else if ( restrictions.length == 1 ) {
             return restrictions[0];
         }
-        throw new UnsupportedOperationException( "Trying to create a restriction for an empty restriction list" );
+        context.getErrors().add( new RuleError( context.getRule(),
+                                                fieldConstraintDescr,
+                                                null,
+                                                "This is a bug: trying to create a restriction for an empty restriction list for field '"+ fieldConstraintDescr.getFieldName() +"' in the rule '" + context.getRule().getName() + "'" ) );
+        return null;
     }
 
     private void build(final RuleBuildContext context,




More information about the jboss-svn-commits mailing list