asonas / chatwork-ruby

MIT License
64 stars 27 forks source link

NoMethodError: undefined method `[]' for nil:NilClass #42

Closed sue445 closed 6 years ago

sue445 commented 6 years ago

https://github.com/asonas/chatwork-ruby/blob/v0.6.1/lib/chatwork/chatwork_error.rb#L12

if body is nil, NoMethodError is raised

Backtrace (in my app)

ChatWork::AuthenticateError: Bearer error="invalid_token", error_description="The access token expired"
File "/app/vendor/bundle/ruby/2.5.0/gems/chatwork-0.6.1/lib/chatwork/base_client.rb" line 27 in handle_response
File "/app/vendor/bundle/ruby/2.5.0/gems/chatwork-0.6.1/lib/chatwork/base_client.rb" line 38 in block (2 levels) in <class:BaseClient>
File "/app/vendor/bundle/ruby/2.5.0/gems/chatwork-0.6.1/lib/chatwork/entity_methods.rb" line 10 in _post
File "/app/vendor/bundle/ruby/2.5.0/gems/chatwork-0.6.1/lib/chatwork/task.rb" line 66 in create
File "/app/app/models/user/api_module.rb" line 23 in block in create_task

NoMethodError: undefined method `[]' for nil:NilClass
File "/app/vendor/bundle/ruby/2.5.0/gems/chatwork-0.6.1/lib/chatwork/chatwork_error.rb" line 12 in from_response
File "/app/vendor/bundle/ruby/2.5.0/gems/chatwork-0.6.1/lib/chatwork/base_client.rb" line 27 in handle_response
File "/app/vendor/bundle/ruby/2.5.0/gems/chatwork-0.6.1/lib/chatwork/base_client.rb" line 38 in block (2 levels) in <class:BaseClient>
File "/app/vendor/bundle/ruby/2.5.0/gems/chatwork-0.6.1/lib/chatwork/token.rb" line 24 in refresh_access_token
File "/app/app/models/user/api_module.rb" line 54 in refresh_access_token