I write an application which is basically just client to http API. I am trying to reuse code from Redis Search sample (DataParser and JsonParser), but when error occurs during the API call, RubyMotion is not able to raise that error. It tries to raise first error in error pointer, which is of NSError and raise expects Exception ancestor.
Is there some new way how to treat HTTP errors in RubyMotion projects?
Received error:
data_parser.rb:7:in `parse:': exception class/object expected (TypeError)
One of codes failing this way:
class DataParser
def self.parse(url)
error_ptr = Pointer.new(:object)
data = NSData.alloc.initWithContentsOfURL(NSURL.URLWithString(url), options:NSDataReadingUncached, error:error_ptr)
unless data
NSLog error_ptr[0].inspect
raise error_ptr[0]
end
data
end
end
