You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cayenne.apache.org by to...@apache.org on 2006/10/26 00:47:18 UTC
svn commit: r467801 - in
/incubator/cayenne/sandbox/CocoaCayenne/CocoaCayenne: CAYObjectContext.h
CAYObjectContext.m
Author: torehalset
Date: Wed Oct 25 15:47:18 2006
New Revision: 467801
URL: http://svn.apache.org/viewvc?view=rev&rev=467801
Log:
ctxt.commitChanges error handling
Modified:
incubator/cayenne/sandbox/CocoaCayenne/CocoaCayenne/CAYObjectContext.h
incubator/cayenne/sandbox/CocoaCayenne/CocoaCayenne/CAYObjectContext.m
Modified: incubator/cayenne/sandbox/CocoaCayenne/CocoaCayenne/CAYObjectContext.h
URL: http://svn.apache.org/viewvc/incubator/cayenne/sandbox/CocoaCayenne/CocoaCayenne/CAYObjectContext.h?view=diff&rev=467801&r1=467800&r2=467801
==============================================================================
--- incubator/cayenne/sandbox/CocoaCayenne/CocoaCayenne/CAYObjectContext.h (original)
+++ incubator/cayenne/sandbox/CocoaCayenne/CocoaCayenne/CAYObjectContext.h Wed Oct 25 15:47:18 2006
@@ -39,7 +39,7 @@
-(void) propertyChanged:(CAYPersistentObject *)object forProperty:(NSString *)property fromOld:(NSObject *)oldValue toNew:(NSObject *)newValue;
-(void) arcPropertyChanged:(CAYPersistentObject *)object forProperty:(NSString *)property fromOld:(NSObject *)oldValue toNew:(NSObject *)newValue;
--(void)commitChanges;
+-(BOOL)commitChanges:(NSError **)outError;
-(void)setEntityResolver:(CAYEntityResolver *)er;
-(CAYEntityResolver *)entityResolver;
Modified: incubator/cayenne/sandbox/CocoaCayenne/CocoaCayenne/CAYObjectContext.m
URL: http://svn.apache.org/viewvc/incubator/cayenne/sandbox/CocoaCayenne/CocoaCayenne/CAYObjectContext.m?view=diff&rev=467801&r1=467800&r2=467801
==============================================================================
--- incubator/cayenne/sandbox/CocoaCayenne/CocoaCayenne/CAYObjectContext.m (original)
+++ incubator/cayenne/sandbox/CocoaCayenne/CocoaCayenne/CAYObjectContext.m Wed Oct 25 15:47:18 2006
@@ -192,7 +192,7 @@
return connection;
}
--(void)commitChanges
+-(BOOL)commitChanges:(NSError **)outError
{
NSLog(@"DEBUG: %i unsaved changes before commit. %@", [diffs count], diffs);
CAYCompoundDiff *diffWithDiffs = [[CAYCompoundDiff alloc] initWithDiffs:diffs];
@@ -213,17 +213,35 @@
}
else if ([result isKindOfClass:[NSError class]])
{
- // TODO: handle returned NSError
- NSLog(@"ERROR: not able to handle NSError commit result", [result class]);
+ // TODO: wrap or change code to make the NSError the most useful for the
+ // framework user?
+ NSLog(@"ERROR: NSError commit result");
+
+ *outError = (NSError *)result;
+
+ return NO;
}
else
{
NSLog(@"ERROR: unknown commit result type %@", [result class]);
+
+ NSString *errorMessage = [[NSString alloc] initWithFormat:@"Unexpected server response: %@", result];
+ NSString *errorStr = NSLocalizedStringFromTable(errorMessage, [[self class] description], @"");
+ [errorMessage release];
+ NSDictionary *userInfoDict = [NSDictionary dictionaryWithObject:errorStr
+ forKey:NSLocalizedDescriptionKey];
+ NSError *error = [[[NSError alloc] initWithDomain:[[self class] description]
+ code:0
+ userInfo:userInfoDict] autorelease];
+ *outError = error;
+
+ return NO;
}
[msg release];
[diffWithDiffs release];
NSLog(@"DEBUG: %i unsaved changes after commit", [diffs count]);
+ return YES;
}
-(void)setEntityResolver:(CAYEntityResolver *)er