db-torque-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Henning Schmiedehausen <...@intermeta.de>
Subject RE: [RFC] Changing retrieveByPK
Date Thu, 23 Jan 2003 15:07:58 GMT
Hi,

fine with me. I just need to distinguish between the "no rows" and "any
other error" cases.

Torque throws "TorqueException" for everything. Now try to do
constructive error handling here... =:-( I ended up very much with

try
{
	... anything ...
}
catch(TorqueException te)
{
	log.error("Torque failed" ,te);
	System.exit(1); // :-)
}

when working outside Turbine...

	Regards
		Henning


On Thu, 2003-01-23 at 16:00, Quinton McCombs wrote:
> I would suggest subclassing TorqueException.  Perhaps TooManyRows and
> NoRows could subclass TorqueException.  The superclass would only be
> thrown for general exceptions.
> 
> This would prevent any existing code from breaking....
> 
> > -----Original Message-----
> > From: Henning P. Schmiedehausen [mailto:hps@intermeta.de] 
> > Sent: Thursday, January 23, 2003 6:57 AM
> > To: turbine-torque-dev@jakarta.apache.org
> > Subject: [RFC] Changing retrieveByPK
> > 
> > 
> > Hi,
> > 
> > I have the following problem:
> > 
> > In Peer.vm there is the following code:
> > 
> > --- cut ---
> >         List v = doSelect(criteria, con);
> >         if (v.size() != 1)
> >         {
> >             throw new TorqueException("Failed to select one 
> > and only one row.");
> >         }
> >         else
> >         {
> >             return ($table.JavaName)v.get(0);
> >         }
> > --- cut ---
> > 
> > I'd like to distinguish between "no such object found" and 
> > "an error occured".
> > 
> > How about changing this to 
> > 
> > --- cut ---
> >         List v = doSelect(criteria, con);
> >         switch (v.size())
> >         {
> >             case 0:
> >                 throw ... some other exception
> > 
> >             case 1:
> >                 break;
> > 
> >             default:
> >                 throw new TorqueException("Failed to select 
> > one and only one row.");
> >         }
> >         return ($table.JavaName)v.get(0);
> > --- cut ---
> > 
> > to make this possible.
> > 
> > 	Regards
> > 		Henning
> > 
> > -- 
> > Dipl.-Inf. (Univ.) Henning P. Schmiedehausen       -- 
> > Geschaeftsfuehrer
> > INTERMETA - Gesellschaft fuer Mehrwertdienste mbH     hps@intermeta.de
> > 
> > Am Schwabachgrund 22  Fon.: 09131 / 50654-0   info@intermeta.de
> > D-91054 Buckenhof     Fax.: 09131 / 50654-20   
> > 
> > --
> > To unsubscribe, e-mail:   
> > <mailto:turbine-torque-dev-> unsubscribe@jakarta.apache.org>
> > 
> > For additional commands, 
> > e-mail: <mailto:turbine-torque-dev-help@jakarta.apache.org>
> > 
> > 
-- 
Dipl.-Inf. (Univ.) Henning P. Schmiedehausen       -- Geschaeftsfuehrer
INTERMETA - Gesellschaft fuer Mehrwertdienste mbH     hps@intermeta.de

Am Schwabachgrund 22  Fon.: 09131 / 50654-0   info@intermeta.de
D-91054 Buckenhof     Fax.: 09131 / 50654-20   


Mime
View raw message