Skip to content

Commit

Permalink
Merge pull request Mantle#661 from kypselia/improved_error
Browse files Browse the repository at this point in the history
Improved error descriptions
  • Loading branch information
robb committed Dec 29, 2015
2 parents 234b698 + ea61b4e commit afa50af
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
6 changes: 6 additions & 0 deletions Mantle/MTLJSONAdapter.h
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,12 @@ extern const NSInteger MTLJSONAdapterErrorInvalidJSONDictionary;
/// does not actually exist in +propertyKeys.
extern const NSInteger MTLJSONAdapterErrorInvalidJSONMapping;

/// An exception was thrown and caught.
extern const NSInteger MTLJSONAdapterErrorExceptionThrown;

/// Associated with the NSException that was caught.
extern NSString * const MTLJSONAdapterThrownExceptionErrorKey;

/// Converts a MTLModel object to and from a JSON dictionary.
@interface MTLJSONAdapter : NSObject

Expand Down
5 changes: 3 additions & 2 deletions Mantle/MTLJSONAdapter.m
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
const NSInteger MTLJSONAdapterErrorExceptionThrown = 1;

// Associated with the NSException that was caught.
static NSString * const MTLJSONAdapterThrownExceptionErrorKey = @"MTLJSONAdapterThrownException";
NSString * const MTLJSONAdapterThrownExceptionErrorKey = @"MTLJSONAdapterThrownException";

@interface MTLJSONAdapter ()

Expand Down Expand Up @@ -343,7 +343,8 @@ - (id)modelFromJSONDictionary:(NSDictionary *)JSONDictionary error:(NSError **)e
#else
if (error != NULL) {
NSDictionary *userInfo = @{
NSLocalizedDescriptionKey: ex.description,
NSLocalizedDescriptionKey: [NSString stringWithFormat:@"Caught exception parsing JSON key path \"%@\" for model class: %@", JSONKeyPaths, self.modelClass],
NSLocalizedRecoverySuggestionErrorKey: ex.description,
NSLocalizedFailureReasonErrorKey: ex.reason,
MTLJSONAdapterThrownExceptionErrorKey: ex
};
Expand Down

0 comments on commit afa50af

Please sign in to comment.