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
------------------------------