apache / openwhisk-client-js

JavaScript client library for the Apache OpenWhisk platform
https://openwhisk.apache.org/
Apache License 2.0
83 stars 53 forks source link

fix handling of request exceptions in client.js #196

Closed alexkli closed 4 years ago

alexkli commented 5 years ago

When a network or internal exception is thrown when making the http request via needle (for example when mocking via unit tests using nock), it would throw a TypeError in Client.handleErrors() because reason.options is not set for those error (reason is the caught error object):

TypeError: Cannot read property 'method' of undefined

This PR fixes it by adding the necessary structure upon errors inside rp().

Included a unit test that uncovers the problem: https://github.com/apache/openwhisk-client-js/pull/196/files#diff-1a5d07059384adab4362f4ed2eed98e2R26

codecov-io commented 5 years ago

Codecov Report

Merging #196 into master will increase coverage by <.01%. The diff coverage is 100%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master     #196      +/-   ##
==========================================
+ Coverage   99.27%   99.27%   +<.01%     
==========================================
  Files          14       14              
  Lines         411      414       +3     
==========================================
+ Hits          408      411       +3     
  Misses          3        3
Impacted Files Coverage Δ
lib/client.js 98.88% <100%> (+0.03%) :arrow_up:

Continue to review full report at Codecov.

Legend - Click here to learn more Δ = absolute <relative> (impact), ø = not affected, ? = missing data Powered by Codecov. Last update 216c65e...b270307. Read the comment docs.