Skip to content
This repository has been archived by the owner on Jul 25, 2019. It is now read-only.

Commit

Permalink
BUGFIX: Don't crash if errors is not a dictionary
Browse files Browse the repository at this point in the history
  • Loading branch information
austintaylor committed Sep 7, 2016
1 parent d7aa30f commit 112a025
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 4 deletions.
10 changes: 7 additions & 3 deletions Classes/UVResponseDelegate.m
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,13 @@ - (void)restConnection:(NSURLConnection *)connection didReturnResource:(id)resou
if (requestContext.statusCode >= 400) {
NSDictionary *userInfo = nil;

if ([resource respondsToSelector:@selector(objectForKey:)])
userInfo = [resource objectForKey:@"errors"];

if ([resource respondsToSelector:@selector(objectForKey:)]) {
id errors = [resource objectForKey:@"errors"];
if (errors && ![errors isKindOfClass:[NSDictionary class]]) {
errors = @{ @"errors": errors };
}
userInfo = errors;
}
NSError *error = [NSError errorWithDomain:@"uservoice" code:requestContext.statusCode userInfo:userInfo];
[requestContext.modelClass didReceiveError:error context:object];

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
LastUpgradeVersion = "0720"
LastUpgradeVersion = "0800"
version = "1.3">
<BuildAction
parallelizeBuildables = "YES"
Expand Down

0 comments on commit 112a025

Please sign in to comment.