Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Merge pull request #83 from sixten/0.9-error-handling

  • Loading branch information...
commit e5093a38ddc7521268c81169800b66cb0b9fe391 2 parents 8d7a490 + 40c4940
Blake Watters authored
View
2  Code/CoreData/RKManagedObject.m
@@ -36,7 +36,7 @@ + (NSFetchRequest*)fetchRequest {
+ (NSArray*)objectsWithFetchRequest:(NSFetchRequest*)fetchRequest {
NSError* error = nil;
NSArray* objects = [[RKManagedObject managedObjectContext] executeFetchRequest:fetchRequest error:&error];
- if (error != nil) {
+ if (objects == nil) {
NSLog(@"Error: %@", [error localizedDescription]);
// TODO: Error handling
}
View
2  Code/CoreData/RKManagedObjectSeeder.m
@@ -89,7 +89,7 @@ - (void)seedObjectsFromFile:(NSString*)fileName toClass:(Class<RKObjectMappable>
NSString* filePath = [[NSBundle mainBundle] pathForResource:fileName ofType:nil];
NSString* payload = [NSString stringWithContentsOfFile:filePath encoding:NSUTF8StringEncoding error:&error];
- if (nil == error) {
+ if (payload != nil) {
// TODO: When we support multiple parsers, we should auto-detect the MIME Type from the file extension
// and pass it through to the mapper
id objects = [_manager.mapper parseString:payload];
View
2  Code/CoreData/RKManagedObjectStore.m
@@ -107,6 +107,8 @@ - (NSError*)save {
NSDictionary* userInfo = [NSDictionary dictionaryWithObject:error forKey:@"error"];
[[NSNotificationCenter defaultCenter] postNotificationName:RKManagedObjectStoreDidFailSaveNotification object:self userInfo:userInfo];
+
+ return error;
}
}
@catch (NSException* e) {
View
9 Code/Network/RKParamsAttachment.m
@@ -65,9 +65,12 @@ - (id)initWithName:(NSString*)name file:(NSString*)filePath {
_MIMEType = [[self mimeTypeForExtension:[filePath pathExtension]] retain];
_bodyStream = [[NSInputStream inputStreamWithFileAtPath:filePath] retain];
- NSError* error = nil;
- _bodyLength = [[[[NSFileManager defaultManager] attributesOfItemAtPath:filePath error:&error] objectForKey:NSFileSize] unsignedIntegerValue];
- if (error) {
+ NSError* error;
+ NSDictionary* attributes = [[NSFileManager defaultManager] attributesOfItemAtPath:filePath error:&error];
+ if (attributes) {
+ _bodyLength = [[attributes objectForKey:NSFileSize] unsignedIntegerValue];
+ }
+ else {
NSLog(@"Encountered an error while determining file size: %@", error);
}
}
View
16 Code/Network/RKRequest.m
@@ -248,7 +248,7 @@ - (void)sendAsynchronously {
- (RKResponse*)sendSynchronously {
NSURLResponse* URLResponse = nil;
- NSError* error = nil;
+ NSError* error;
NSData* payload = nil;
RKResponse* response = nil;
@@ -266,13 +266,15 @@ - (RKResponse*)sendSynchronously {
}
payload = [NSURLConnection sendSynchronousRequest:_URLRequest returningResponse:&URLResponse error:&error];
+ if (payload != nil) error = nil;
+
response = [[[RKResponse alloc] initWithSynchronousRequest:self URLResponse:URLResponse body:payload error:error] autorelease];
-
- if (error) {
- [self didFailLoadWithError:error];
- } else {
- [self didFinishLoad:response];
- }
+
+ if (payload == nil) {
+ [self didFailLoadWithError:error];
+ } else {
+ [self didFinishLoad:response];
+ }
} else {
NSString* errorMessage = [NSString stringWithFormat:@"The client is unable to contact the resource at %@", [[self URL] absoluteString]];
NSDictionary *userInfo = [NSDictionary dictionaryWithObjectsAndKeys:
Please sign in to comment.
Something went wrong with that request. Please try again.