[jboss-jira] [JBoss JIRA] Created: (JBRULES-2545) Exception handling of KnowledgeBuilder .add for ruleflows should report compilation errors, not null-pointer exception

David Goldstein (JIRA) jira-events at lists.jboss.org
Thu Jun 10 10:33:38 EDT 2010


Exception handling of KnowledgeBuilder .add for ruleflows should report compilation errors, not null-pointer exception
----------------------------------------------------------------------------------------------------------------------

                 Key: JBRULES-2545
                 URL: https://jira.jboss.org/browse/JBRULES-2545
             Project: Drools
          Issue Type: Support Patch
      Security Level: Public (Everyone can see)
          Components: drools-compiler
    Affects Versions: 5.1.0.M2
         Environment: Windows XP, Eclipse plugin
            Reporter: David Goldstein
            Assignee: Mark Proctor


Compiling and adding a ruleflow via KnowledgeBuilder's add method often returns a simple null-pointer exception when information about the actual node that did not compile is available.  While one can make a work-around using:

            try {
                kbuilder.add(workFlow, workFlowtype);
            }
           catch(Exception t){
                KnowledgeBuilderErrors errors = kbuilder.getErrors();
                if (errors.size() > 0) 
                  for (KnowledgeBuilderError error: errors) 
                      System.err.println(error);
                  }
              }
                      throw new IllegalArgumentException("Could not parse knowledge.");
            }
...
      }

throwing an exception with the actual build problem in the message seems appropriate so that users see an error describing the build problem when using traditional exception handling:

            try {
                kbuilder.add(workFlow, workFlowtype);
            }
           catch (Exception t) {
                t.printStackTrace()
           }
 

-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: https://jira.jboss.org/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira

       



More information about the jboss-jira mailing list