HipByte / Flow

Cross-platform libraries for RubyMotion
BSD 2-Clause "Simplified" License
141 stars 29 forks source link

[Android] Net module - only supports success calls? #44

Open rafaeliga opened 8 years ago

rafaeliga commented 8 years ago

When my api returns any status code different from 200, I get this error/crash:

--------- beginning of main --------- beginning of system (main)> 08-19 15:56:03.087 31788 31952 E br/com/rubythree/hello: Java exception raised: java.io.FileNotFoundException: http://192.168.1.119:3000/api/tokens.json --------- beginning of crash

My call:

begin
 Net.post(url, options) do |response|
  p response.body
 end
rescue => e
 p e
 p e.message
end

I try to add a begin/rescue blocks, but it didnt work.

jjaffeux commented 8 years ago

Please provide a sample I can run

rafaeliga commented 8 years ago

I created a new project to test:

motion create --template=flow HelloFlowSample

main_activity.rb

class MainActivity < Android::App::Activity
  def onCreate(savedInstanceState)
    Store.context = self
    super

    Net.get('http://www.google.com/error') do |response|
      p "====== #{response.status} ======="
    end    
  end
end

Crash/error:

--------- beginning of system --------- beginning of main (main)> 08-19 16:23:41.134 7839 7944 E com/yourcompany/helloflowsample: Java exception raised: java.io.FileNotFoundException: http://www.google.com/error --------- beginning of crash

rafaeliga commented 8 years ago

hey @jjaffeux, did you reproduce the crash?

I would try to debug the Java files....can you help me with that?

thanks

rafaeliga commented 7 years ago

@jjaffeux can you help me to start on debug and fix this error on Flow/Net? Which file should be looking? android/request.rb(https://github.com/HipByte/Flow/blob/master/flow/net/android/request.rb)? Thanks!

rafaeliga commented 7 years ago

@jjaffeux please check the pull request that I created when you have a chance! Thanks!