• 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: ps: database failures not rolling up to eof stack ??
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: ps: database failures not rolling up to eof stack ??


  • Subject: Re: ps: database failures not rolling up to eof stack ??
  • From: Jake Fisher <email@hidden>
  • Date: Fri, 28 Jan 2011 22:09:55 -0500

In ERXSqlHelper-->MySQLHelper-->handleDatabaseException it swallows
the jdbc exception whole and never reports it. The best you ever get
bubbled up to you in a completely non-descriptive custom validator
exception.........

I have been meaning to log this as an issue for a long time, sorry for
that, unless of course that is the intended behavior though I can't
see why it would be....

~Jake



Code snippet from ERXSQLHelper reposted below for evaluation by more eyes.

------
		@Override
		public boolean handleDatabaseException(EODatabaseContext
databaseContext, Throwable throwable) {
			if(throwable instanceof EOGeneralAdaptorException) {
				EOGeneralAdaptorException e = (EOGeneralAdaptorException)throwable;
				NSDictionary userInfo = e.userInfo();
				EOAdaptorOperation failedOp =
userInfo==null?null:(EOAdaptorOperation)userInfo.objectForKey(EOAdaptorChannel.FailedAdaptorOperationKey);
				if(failedOp != null && failedOp.exception() instanceof
JDBCAdaptorException) {
					JDBCAdaptorException ae = (JDBCAdaptorException)failedOp.exception();

					// MySQL error codes:
http://dev.mysql.com/doc/refman/5.0/en/error-messages-server.html
					switch(ae.sqlException().getErrorCode()) {

					case 1062: //Violates unique constraint
						handleUniqueConstraintAdaptorException(databaseContext, failedOp);
						break;

					default:

					}
				}
			}
			return false;
		}

		/**
		 * Throws a validation exception for a unique constraint failure.
		 * @param context The database context
		 * @param failedOp The operation that failed
		 * @throws NSValidation.ValidationException The exception thrown.
The key for the validation template strings file is
<code>UniqueConstraintException</code>
		 */
		protected void
handleUniqueConstraintAdaptorException(EODatabaseContext context,
EOAdaptorOperation failedOp) throws NSValidation.ValidationException {
			NSValidation.ValidationException ve =
ERXValidationFactory.defaultFactory().createCustomException(null,
"UniqueConstraintException");
			throw ve;
		}
	}



On Fri, Jan 28, 2011 at 5:22 PM, Chuck Hill <email@hidden> wrote:
>
> On Jan 28, 2011, at 2:16 PM, Simon wrote:
>
>> Check for a custom EC, custom DB context, or delegates for either of those as a place to start.  At what point are you NOT seeing it?  Could it just be getting ignored at the UI level?  I have seen "clever" handling like this:
>>
>> public WOActionResults save() {
>>    try {
>>        editingContext().saveChanges();
>>    }
>>    catch (Exception e) {
>>    }
>>    return context().page();
>> }
>>
>> nice :-) we have 'L' plates in the office that we dish out to people for that kind of stuff
>
> We used to have a cane, it was a caning offense.
>
>
>> ('L' plates in the UK are for learner drivers - i have no idea if that translates around the globe..)
>
> It does in British Columbia.  We also have N for the Newfie drivers (or is that New drivers...).   I can think of a few others that would be useful.
>
>
>>  > ps. is WOVNG still progressing ?
>>
>> Yes, about as well as your exception.  :-P
>>
>> ahhh. ok. i guessed that form the number of files release on sourceforge :-P
>>
>> if there is anything worth punting out then please do so - we're about to start reviewing how we can improve validation and it would be good to see what you were trying to do with that stuff.
>
> I don't think much more got done, though I have more internally.  It is an interest of mine, so I would be keen on being part of the discussion.
>
>
> Chuck
>
> --
> Chuck Hill             Senior Consultant / VP Development
>
> Practical WebObjects - for developers who want to increase their overall knowledge of WebObjects or who are trying to solve specific problems.
> http://www.global-village.net/products/practical_webobjects
>
>
>
>
>
>
>
>
>  _______________________________________________
> 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
>
 _______________________________________________
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

  • Follow-Ups:
    • Re: ps: database failures not rolling up to eof stack ??
      • From: Chuck Hill <email@hidden>
References: 
 >ps: database failures not rolling up to eof stack ?? (From: Simon <email@hidden>)
 >Re: ps: database failures not rolling up to eof stack ?? (From: Chuck Hill <email@hidden>)
 >Re: ps: database failures not rolling up to eof stack ?? (From: Simon <email@hidden>)
 >Re: ps: database failures not rolling up to eof stack ?? (From: Chuck Hill <email@hidden>)
 >Re: ps: database failures not rolling up to eof stack ?? (From: Simon <email@hidden>)
 >Re: ps: database failures not rolling up to eof stack ?? (From: Chuck Hill <email@hidden>)

  • Prev by Date: Re: AjaxTabbedPanel - exception while handling request
  • Next by Date: Re: ps: database failures not rolling up to eof stack ??
  • Previous by thread: Re: ps: database failures not rolling up to eof stack ??
  • Next by thread: Re: ps: database failures not rolling up to eof stack ??
  • Index(es):
    • Date
    • Thread