Bizə ətraflı DROOLS istisna user təsvir edək. DROOLS In, default istisna handler kimi tanınır “Nəticə Exception Handler”. Bu, aşağıdakı kimi minimum məlumat verir.
bir) qayda
b) istisna yaşandı harada
c) java yığını iz ilə səbəbinin
DROOLS də öz xüsusi istisna yazmaq imkan verir handler.The “ConsequenceException” genişləndirir “java.lang.RuntimeException”.konstruktor imza aşağıda verilmişdir.
ConsequenceException(throwable rootCause, Rule qayda)
Yalnız metodu “ictimai Rule getRule()”.
The “ConsequenceExceptionHandler” həyata bir interface handler.The yalnız xüsusi yazmaq üçün mövcud aşağıda verilir və xüsusi user etmək üzerine deyil.
etibarsız handleException(aktivləşdirilməsi aktivasiya,
WorkingMemory workingMemory,
istisna istisna)
Nümunə code aşağıdakı kimidir :-
import java.io.Externalizable;
import org.drools.runtime.rule.ConsequenceExceptionHandler;
public class CustomConsequenceExceptionHandler
implements ConsequenceExceptionHandler, Externalizable {
public void handleException( Activation activation,
WorkingMemory workingMemory,
Exception exception ){
// Write custom handling code here.
}
}
xüsusi user yaxşılaşdırılması “RuntimeException” can also be extended.
For identifying rule file (.drl) compilation error, “hasErrors()” method of “KnowledgeBuilder” class can be used. Following is a sample code snippet for implementing the method.
KnowledgeBuilder kbuilder = KnowledgeBuilderFactory.newKnowledgeBuilder();
kbuilder.add(ResourceFactory.newFileResource("D:/Workspace/TestProj/src/Test.drl"), ResourceType.DRL);
əgər (kbuilder.hasErrors()) {
System.out.println(kbuilder.getErrors().toString());
throw new RuntimeException(“Unable to compile ”Test.drl”.”);
}