-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 posts ] 
Author Message
 Post subject: Catching and rethrowing specific error
PostPosted: Wed Feb 23, 2005 5:34 pm 
Beginner
Beginner

Joined: Tue Nov 02, 2004 1:34 pm
Posts: 45
Now that I have the <timestamp> feature working....such that I catch the situation where someone has changed a record while a user had the page open -- I'm stuck trying to figure out how to catch that specific error.

In the following....I can't throw StaleObjectStateException -- the code won't compile.

How do I handle this...basically, in my struts action class I want to distinguish the StaleObjectStateException and forward onto a different error page just for that error.

Lee


Code:
   public String makePersistent(Metric metric) throws InfrastructureException, StaleObjectStateException
   {
      try {
         HibernateUtil.getSession().saveOrUpdate(metric);
         HibernateUtil.getSession().flush();
      }  catch (StaleObjectStateException se) {
         throw StaleObjectStateException;
      } catch (HibernateException ex) {
         throw new InfrastructureException(ex);
      } catch (Exception e) {
         throw new InfrastructureException(e);
      }
      return metric.getMetricId().toString();
   }


Top
 Profile  
 
 Post subject:
PostPosted: Wed Feb 23, 2005 5:39 pm 
Beginner
Beginner

Joined: Tue Nov 02, 2004 1:34 pm
Posts: 45
doh! nevermind.

I needed to

Code:
throw se;


not

Code:
throw StaleObjectStateException;



Lee


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 posts ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.