0

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?

I am not using BW::HTTP since I found it was deprecated.

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
Mailo Světel
  • 24,002
  • 5
  • 30
  • 40

1 Answers1

0

Highly recommended to use AFMotion: https://github.com/clayallsopp/afmotion

arashb31
  • 473
  • 6
  • 12