• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Need some advice on handling EO validation errors
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Need some advice on handling EO validation errors


  • Subject: Re: Need some advice on handling EO validation errors
  • From: Paul Lynch <email@hidden>
  • Date: Fri, 7 Dec 2007 17:56:56 +0000


On 7 Dec 2007, at 16:03, Alan Ward wrote:


The unsaved objects(s) are still in your EOEditingContext and thus any future attempts to save
will try to save them again (along with any subsequent changes). The approach that you describe
below is not the best one. What you want to do is to catch the exception from ec.saveChanges()
and depending on what caused it either a) fix your code to prevent it happening, b) modify the
EO's in your EC such that they can be saved or c) revert the EC and abandon the unsaved changes.
If you do none of the above and keep trying to save that editingContext then you'll just keep getting
the same error as EOF tries to persist your changes to the database.

This is good advice. If you want to discard changes from your editing context, use revert(); or, in some cases, refetch() may be appropriate - but usually revert() is correct.


On Dec 7, 2007, at 8:48 AM, Greg Lappen wrote:

Hi all,

I just recently ran into an issue where my application tried to save a new object to the database, the save failed, and every subsequent save failed with the same error. It seems that WebObjects maintains a queue of updates/saves to write to the database, and when one fails, it essentially clogs up the queue because WO keeps trying to save it eveytime someone calls saveChanges() on an editing context. What I'd like to do is set up a global exception handler in my application that runs whenever an exception is not caught by my code, and in that error handler I want to reset the whole EnterpriseObject stack - the cache, the update/save queue, everything - so that other work in the application can continue and not worry about cache corruption or anything like that.

Is this possible to do? Anyone know how to do it?

It is possible to do this. Implement handleException in your Application class; this isn't the best place to handle database validation errors, but it's one way of preventing uses seeing the famous WO exception page.


Paul
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Webobjects-dev mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden


References: 
 >Need some advice on handling EO validation errors (From: Greg Lappen <email@hidden>)
 >Re: Need some advice on handling EO validation errors (From: Alan Ward <email@hidden>)

  • Prev by Date: Re: new rules for parsing .wod files
  • Next by Date: Re: Need some advice on handling EO validation errors
  • Previous by thread: Re: Need some advice on handling EO validation errors
  • Next by thread: Re: Need some advice on handling EO validation errors
  • Index(es):
    • Date
    • Thread