lib/ios/sugarcube-factories/nserror.rb in sugarcube-3.2.0 vs lib/ios/sugarcube-factories/nserror.rb in sugarcube-3.3.0
- old
+ new
@@ -1,7 +1,14 @@
class NSError
- def self.new(message='Error', options={})
+ # @example
+ # NSError.error('just a simple error message')
+ # NSError.error('just a simple error message',
+ # domain: 'foo',
+ # code: 255,
+ # userInfo: { 'object' => 'foo' }
+ # )
+ def self.error(message='Error', options={})
domain = options[:domain] || 'Error'
code = options[:code] || 0
info = { NSLocalizedDescriptionKey => message }
if options[:userInfo]
info.merge! options[:userInfo]