RT 今天使用了一下 gem 'zhima_auth' 按照 git 上给的例子测试了一下,报
irb(main):013:0* ZhimaAuth.certify params
ZhimaAuth::InvalidResponse: ZhimaAuth::InvalidResponse
from /usr/local/lib/ruby/gems/2.2.0/gems/zhima_auth-0.3.0/lib/zhima_auth/validation.rb:31:in `check_initialize_response'
from /usr/local/lib/ruby/gems/2.2.0/gems/zhima_auth-0.3.0/lib/zhima_auth/request.rb:41:in `get_biz_no'
from /usr/local/lib/ruby/gems/2.2.0/gems/zhima_auth-0.3.0/lib/zhima_auth.rb:24:in `certify'
from (irb):13
from /usr/local/lib/ruby/gems/2.2.0/gems/railties-4.2.5.2/lib/rails/commands/console.rb:110:in `start'
from /usr/local/lib/ruby/gems/2.2.0/gems/railties-4.2.5.2/lib/rails/commands/console.rb:9:in `start'
from /usr/local/lib/ruby/gems/2.2.0/gems/railties-4.2.5.2/lib/rails/commands/commands_tasks.rb:68:in `console'
from /usr/local/lib/ruby/gems/2.2.0/gems/railties-4.2.5.2/lib/rails/commands/commands_tasks.rb:39:in `run_command!'
from /usr/local/lib/ruby/gems/2.2.0/gems/railties-4.2.5.2/lib/rails/commands.rb:17:in `<top (required)>'
from /usr/local/lib/ruby/gems/2.2.0/gems/activesupport-4.2.5.2/lib/active_support/dependencies.rb:274:in `require'
from /usr/local/lib/ruby/gems/2.2.0/gems/activesupport-4.2.5.2/lib/active_support/dependencies.rb:274:in `block in require'
from /usr/local/lib/ruby/gems/2.2.0/gems/activesupport-4.2.5.2/lib/active_support/dependencies.rb:240:in `load_dependency'
from /usr/local/lib/ruby/gems/2.2.0/gems/activesupport-4.2.5.2/lib/active_support/dependencies.rb:274:in `require'
from /mnt/apix/qianbao/bin/rails:9:in `<top (required)>'
from /usr/local/lib/ruby/gems/2.2.0/gems/activesupport-4.2.5.2/lib/active_support/dependencies.rb:268:in `load'
from /usr/local/lib/ruby/gems/2.2.0/gems/activesupport-4.2.5.2/lib/active_support/dependencies.rb:268:in `block in load'
from /usr/local/lib/ruby/gems/2.2.0/gems/activesupport-4.2.5.2/lib/active_support/dependencies.rb:240:in `load_dependency'
from /usr/local/lib/ruby/gems/2.2.0/gems/activesupport-4.2.5.2/lib/active_support/dependencies.rb:268:in `load'
from /usr/local/lib/ruby/2.2.0/rubygems/core_ext/kernel_require.rb:54:in `require'
from /usr/local/lib/ruby/2.2.0/rubygems/core_ext/kernel_require.rb:54:in `require'
from -e:1:in `<main>'irb(main):014:0>
报错提示太少了,没有思路,就看了下提示的 /usr/local/lib/ruby/gems/2.2.0/gems/zhima_auth-0.3.0/lib/zhima_auth/validation.rb:31:in `check_initialize_response' 的源码, 发现报错信息不一样,感觉比较差异,是我的排错方式不对吗?
def check_initialize_response response
raise ZhimaAuth::InvalidResponse, "Initialize request failed" unless (response.is_a? Hash) && response["zhima_customer_certification_initialize_response"]
response_code = response["zhima_customer_certification_initialize_response"]["code"]
if response_code != "10000"
response_msg = response["zhima_customer_certification_initialize_response"]["sub_msg"]
raise ZhimaAuth::InvalidResponse, "#{response_code}#{response_msg}"
end
true
end
请教各位大神啦