This week's book giveaway is in the Jobs Discussion forum.
We're giving away four copies of Java Interview Guide and have Anthony DePalma on-line!
See this thread for details.
The moose likes Other JSE/JEE APIs and the fly likes Not knowing how to catch Errors Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Java Interview Guide this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Java » Other JSE/JEE APIs
Bookmark "Not knowing how to catch Errors" Watch "Not knowing how to catch Errors" New topic

Not knowing how to catch Errors

Maganti Suryanarayana Murthy

Joined: Apr 09, 2012
Posts: 10

Hi, I am using drools i.e., a fire engine. Instead of writing the business logic in java i am using text based rules. Everything is fine but i have doubt how to assign the error messages or warning messages to the corresponding object which i am inserting in session. I want to set the error messages to the pojo class so that in UI i can display it. Please find the code below.

SecurityRules.drl File

ServiceImplementation class. The problem is here. I am not understanding how to set error messages to UserLogin Pojo class. I have written one logic please correct me. I think what i have written is not setting the error messages to pojo class.

the code is working fine. I am getting the errors also and i am uning the condition that if the size of errors > 0 dont call save or update method. Upto here no problem. The problem is how to set the error message to pojo class so that in UI i can display it.

Maganti Surya
Prabaharan Gopalan
Ranch Hand

Joined: Oct 16, 2009
Posts: 66

I didn't go through the classes but I'm curious, why would you think this is a Java problem and not some configuration in Drools?

Googling doesn't make you a genius. But not Googling makes you dumber.
dennis deems
Ranch Hand

Joined: Mar 12, 2011
Posts: 808
I don't recommend setting an attribute on the object that is passed to the service. Better to return a collection of Messages from the service method. Also create a custom exception class that allows you to set your Message objects on it -- but be careful to differentiate these from the message attribute on the Throwable class. When you throw an exception, throw your custom exception type with the messages populated.
Maganti Suryanarayana Murthy

Joined: Apr 09, 2012
Posts: 10

I can able to return the collection of messages in the service class. But the problem is that i want to set those messages to Object as it should be passed to VO.

I agree. Here's the link:
subject: Not knowing how to catch Errors
It's not a secret anymore!