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 protected]> 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 protected])
>> Help/Unsubscribe/Update your Subscription:
>> http://lists.apple.com/mailman/options/webobjects-dev/fisherja%40gmail.com
>>
>> This email sent to [email protected]
>>
--
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
smime.p7s
Description: S/MIME cryptographic signature
_______________________________________________ Do not post admin requests to the list. They will be ignored. Webobjects-dev mailing list ([email protected]) Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/webobjects-dev/archive%40mail-archive.com This email sent to [email protected]
