steemit / steem-ruby

Steem-ruby is the official Ruby library for the Steem blockchain
MIT License
9 stars 15 forks source link

Hive Error Handlers #17

Closed inertia186 closed 2 years ago

inertia186 commented 5 years ago

As a developer using steem-ruby, I would like steem-ruby to handle errors from hivemind backed nodes, so that I can debug my apps easier.

This change does two things:

  1. It updates the tests so that if a node is backed by hivemind, and thus disables tags_api and follow_api, the tests that rely on those plugins are just skipped.
  2. It handles and whitelists hivemind specific errors so that these tests pass.

Before this change, but after api.steemit.com changed configuration to include hivemind backed methods, the previous revision would have the following errors when running the test suite (e.g., running the command bundle exec rake test):

267 runs, 1628 assertions, 2 failures, 39 errors, 18 skips

For these tests, after this revision, the errors all pass when using the default production node.

Application Impact

When whitelisting errors, this just means steem-ruby will not raise Steem::UnknownError but will raise more meaningful errors, like Steem::ArgumentError or Steem::HivemindArgumentError (which itself descends from Steem::ArgumentError).

To achieve this, steem-ruby will now conditionally check the response for the .error key (like before) or the .result.error key, if the error originates from hivemind.