Sha256: b929409c6005a552cd4d72f43c744109685d02c35f19e8bc485b048bd78616ed

Contents?: true

Size: 516 Bytes

Versions: 3

Compression:

Stored size: 516 Bytes

Contents

class Exercism
  class CLI
    class MonitoredRequest
      attr_reader :api

      def initialize(api)
        @api = api
      end

      def request(action, *args)
        begin
          response = api.send(action, *args)
          response_body = JSON.parse(response.body)

          abort response_body["error"] if response_body["error"]

          yield response, response_body
        rescue Exception => e
          abort "There was an issue with your request.\n#{e}"
        end
      end
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
exercism-0.0.28 lib/cli/monitored_request.rb
exercism-0.0.27 lib/cli/monitored_request.rb
exercism-0.0.26 lib/cli/monitored_request.rb