New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix crash on invalid key path #230
Fix crash on invalid key path #230
Conversation
It's a little hard to tell what this is fixing. From the test, am I correct in understanding that it fixes a crash when a nested key path is specified in If so, we should fix this by stepping through the JSON dictionary manually, not catching exceptions. Exceptions in Objective-C are generally used to indicate unrecoverable errors, so catching them is rarely safe. (Mantle does so as a convenience for release code, and the value of even that has been debated.) |
Yep it fix exactly that case. What exactly you mean with "stepping through the JSON dictionary manually" ? I mean, given the test case:
with a + JSONKeyPathsByPropertyKey like this:
should we fill *error with a new error type an return nil from -(id)initWithJSONDictionary better than an Exception? or step over that key and continue with no error? |
I mean that we shouldn't be executing code which will cause Instead, we should follow a generalized version of these steps:
|
Modified fix to avoid sending an exception an returning an error instead |
Thank you! I made some minor formatting changes in df03aa9, but otherwise this looks great! 🌟 |
Fixed a crash when an invalid key path is indicated for a key in the JSONKeyPathsByPropertyKey method