cayenne-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Andrey Razumovsky <razumovsky.and...@gmail.com>
Subject Re: How can I handle validation exception?
Date Thu, 12 Mar 2009 09:08:04 GMT
At least in 3.0 ValidationException is runtime exception (extends
CayenneRuntimeException), so no "throws" declaration is required! Anyways,
if something's still wrong for you, you can try checking the type in catch
block:

catch(Exceprion ex) {
  if (ex instanceof ValidationException) {
    ...
  }
}

2009/3/12 Νίκος Παράσχου <niparasc@gmail.com>

> Maybe I didn't state it clearly. When I said:
>
> "The problem is that commitChanges() doesn't throw directly a
> ValidationException so I cannot catch it in the catch block (it throws a
> CayenneRuntimeException)"
>
> I meant that I can't write the following because it can't be compiled
> (note that a ValidationException is caught):
>
> try {
>        context.commitChanges();
> }
> catch(ValidationException vex) {
>        // ...
> }
>
> That is what I meant by saying "directly" (to be able to write
> catch(ValidationException vex)).
>
> A ValidationException is thrown if there is a failure (so it is not a
> bug). Sorry for confusing you.
>
> My question is: How can I get the validationResult inside the block
> catch() if I write
>
> catch(Exception exc) {
>        // ...
> }
>
> What is the suggested way of getting the failures produced during
> validation?
>
> Nikos
>
> Στις 12-03-2009, ημέρα Πεμ, και ώρα 10:22 +0200, ο/η Andrus Adamchik
> έγραψε:
> > On Mar 12, 2009, at 9:41 AM, Νίκος Παράσχου wrote:
> >
> > > The problem is that commitChanges() doesn't throw directly a
> > > ValidationException so I cannot catch it in the catch block (it
> > > throws a
> > > CayenneRuntimeException)
> >
> > Which version of Cayenne? This could be a bug.
> >
> > Andrus
> >
>
>

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message