Re: ps: database failures not rolling up to eof stack ??
Re: ps: database failures not rolling up to eof stack ??
- Subject: Re: ps: database failures not rolling up to eof stack ??
- From: Ramsey Gurley <email@hidden>
- Date: Sat, 29 Jan 2011 08:48:39 -0500
Someone already beat you to it Jake,
http://issues.objectstyle.org/jira/browse/WONDER-664
And as usual, Chuck Hill is right (^_^)
The method in question throws or returns false. Following the methods up the call stack, I see databaseContextShouldHandleDatabaseException returns !handled. So that returns true. That in turn is called by _delegateHandledDatabaseException in EODatabaseContext which returns the !blah.booleanValue(). So that returns false. And that method is called by the catch block of saveChangesInEditingContext(). The call looks like
if(_delegateHandledDatabaseException) {blah} else { rollback(); throws}
In short, the problem isn't that the code swallows. The problem appears to be that the code throws without calling context.rollbackChanges() first. However, since this little section of code appears to be so roundly despised by all, I'll just remove the error handling altogether and you guys can handle the EOGeneralAdaptorExceptions yourselves.
Ramsey
On Jan 28, 2011, at 10:18 PM, Chuck Hill wrote:
>
> On Jan 28, 2011, at 7:09 PM, Jake Fisher wrote:
>
>> 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);
>
> Thinking this should return true here.
>
>> break;
>>
>> default:
>>
>> }
>> }
>> }
>> return false;
>
> This is * @return whether or not the SQL helper can handle this exception
> so it should be OK.
>
>
>> }
>>
>> /**
>> * 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
>>>
>
> --
> 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
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