RESOLVED FIXED 111487
Objective-C API: JSValue should implement init and return nil in exceptional cases
https://bugs.webkit.org/show_bug.cgi?id=111487
Summary Objective-C API: JSValue should implement init and return nil in exceptional ...
Mark Hahnenberg
Reported 2013-03-05 15:05:37 PST
In keeping with good Objective-C practice, JSValue should override init and throw an exception since there's not really a way to put the returned object in a coherent state that won't crash at some point later in time. Better to fail fast.
Attachments
patch (1.51 KB, patch)
2013-03-05 15:07 PST, Mark Hahnenberg
no flags
return nil (1.57 KB, patch)
2013-03-05 15:20 PST, Mark Hahnenberg
mhahnenberg: review-
updated change log (1.55 KB, patch)
2013-03-05 15:24 PST, Mark Hahnenberg
no flags
Mark Hahnenberg
Comment 1 2013-03-05 15:07:49 PST
Mark Hahnenberg
Comment 2 2013-03-05 15:09:11 PST
Darin Adler
Comment 3 2013-03-05 15:12:54 PST
Comment on attachment 191576 [details] patch View in context: https://bugs.webkit.org/attachment.cgi?id=191576&action=review > Source/JavaScriptCore/API/JSValue.mm:955 > + @throw [NSException exceptionWithName:@"InvalidMessageException" > + reason:@"JSValue cannot safely support init." > + userInfo:nil]; Why throw? Just return nil. And the initWithValue method should also return nil when the arguments are nil. That’s how Cocoa init functions normally work. Unless I’m missing some compelling argument for throwing exceptions instead. Please don’t align the lines like this. WebKit coding style says just indent 4 spaces.
Mark Hahnenberg
Comment 4 2013-03-05 15:20:00 PST
Created attachment 191579 [details] return nil
Mark Hahnenberg
Comment 5 2013-03-05 15:21:10 PST
Comment on attachment 191579 [details] return nil Need to update ChangeLog.
Mark Hahnenberg
Comment 6 2013-03-05 15:24:19 PST
Created attachment 191582 [details] updated change log
WebKit Review Bot
Comment 7 2013-03-05 16:18:37 PST
Comment on attachment 191582 [details] updated change log Clearing flags on attachment: 191582 Committed r144843: <http://trac.webkit.org/changeset/144843>
WebKit Review Bot
Comment 8 2013-03-05 16:18:40 PST
All reviewed patches have been landed. Closing bug.
Note You need to log in before you can comment on or make changes to this bug.