In DE the replacement would be literally
c : com.ibm.rules.engine.ruledef.runtime.RuleEngine() from com.ibm.rules.engine.ruledef.runtime.RuleEngine.this;
Note however that we have improved the pattern for the exception handler using a ThreadLocal variable which makes the initialization simpler and less intrusive. No need for this particular rule.
I have attached the sample illustration the use of the variable.
You will check implementation of exception handler and the init and end task of the ruleflow.
Bom methods are added to make the process easier.
I hope this helps,
Alain
------------------------------
Alain Robert
------------------------------
Original Message:
Sent: Wed February 19, 2025 12:37 AM
From: Showkat Ali Beig
Subject: How to set the custom exception object in the response from CustomExceptionHandler in ODM
Hi Alain Robert,
We have recently migrated our on-premise ODM version to the latest ODM on Cloud. During this migration, we are receiving a warning related to the use of legacy classic rule engine APIs, specifically with the IlrContext
class in our technical rule implementation. The line of code c: IlrContext()
needs to be replaced to support the Decision Engine.
Could you please advise on how we can replace this line (c: IlrContext()
) to ensure compatibility with the Decision Engine? Additionally, if you have any sample exception handling code or a zip file for Decision Engine, could you kindly share it?
Your prompt assistance would be highly appreciated.
------------------------------
Showkat Ali Beig
Original Message:
Sent: Tue January 16, 2024 05:30 PM
From: Alain Robert
Subject: How to set the custom exception object in the response from CustomExceptionHandler in ODM
You can access the response object explicitly from the handleActionException method using the RuleInstance argument to retrieve a parameter
For example
response = (Response) ruleInstance.getEngineData().get("response");
In the method handleConditionException there is no way to access the engine directly.
You can use a side effect to initialize the local attribute response with an action exception and reuse it in the handleConditionException method afterward.
You can refine the process by creating a rule that is called at the beginning of the ruleflow and intentionally throws an exception:
when {
c : IlrContext() from ?context;
}
then {
throw new Exception( "initializing exception handler");
}
In the handleActionException you initialize the object response you want to reuse and ignore the exception because ruleInstance.getRuleName() equals the name of the rule created to fail.
------------------------------
Alain Robert
Original Message:
Sent: Mon January 15, 2024 08:48 PM
From: Anishia Casmir Thomas
Subject: How to set the custom exception object in the response from CustomExceptionHandler in ODM
How to set the custom exception object in the response from CustomExceptionHandler in ODM?
I am in the process of migrating ODM 8.9.2 rules to 8.12. I would like to set custom exception message and code and send it back in the response object. But would like to get some guidance on how to pass the response object to the Custom Exception Handler class.
------------------------------
Anishia Casmir Thomas
------------------------------