• 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: D2W Exception Handling
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: D2W Exception Handling


  • Subject: Re: D2W Exception Handling
  • From: Ramsey Gurley <email@hidden>
  • Date: Fri, 26 Aug 2011 08:51:58 -0700

On Aug 26, 2011, at 2:05 AM, David Avendasora wrote:

> Hey D2Wers,
>
> So, I have business logic that executes in the setter of one of my attributes.

In the setter?  Any reason why you don't use validate<Key>() or maybe validateFor*()?  I've learned the hard way that business logic in a setter is a sign of bad things to come.  It's like exposing PKs and FKs.  It works… sorta, for a while… but sooner or later… BLAM!

> It's checking to make sure that at least one of a set of objects has a flag set. If you try to remove the flag off the last object it should not allow it and throw and exception.
>
> All that works just fine.
>
> Now I want to catch that exception and display it to the user in a friendly way. Ideally basically the same as how standard validation exceptions are displayed in red at the top of the page in ERModernLook.
>
> I've tried throwing a ValidationException and also tried other exceptions, and either it is ignored with no user feedback (ValidationException), or I get the standard, completely disruptive exception page (for all others).
>
> I've tried to find the extension point to put in my own exception handling, but it's apparently not where I thought it was - ERD2WInspectPage#tryToSaveChanges.
>
> Am I doing it wrong, or just looking in the wrong place?
>
> Dave

I suspect your validation exception may be getting swallowed in ERD2WPage's validationFailedWithException method.  Put a breakpoint in there and follow the execution.  If you throw an ERXValidationException and the d2wContext().propertyKey() is null, then the exception never makes it into the error messages dictionary.

I've planned on fixing this, but I want to make the validation handling use a plugable delegate with a default similar to the one now.  That way, I hope to build a new implementation so that I can provide enhanced validation on something like an editable list page where you may have multiple objects with different validation exceptions related to them.

Ramsey


Attachment: smime.p7s
Description: S/MIME cryptographic signature

 _______________________________________________
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: 
 >D2W Exception Handling (From: David Avendasora <email@hidden>)

  • Prev by Date: Re: Dynamic loading of a component into a container?
  • Next by Date: Re: D2W Boolean Search
  • Previous by thread: D2W Exception Handling
  • Next by thread: Re: Dynamic loading of a component into a container?
  • Index(es):
    • Date
    • Thread