Sha256: d206e5daca76b8f2e703b1850eab25cfc4902aea6c6771cda8c2c4e6c9cff534

Contents?: true

Size: 464 Bytes

Versions: 7

Compression:

Stored size: 464 Bytes

Contents

module Terminal
  class APITimeoutError < StandardError; end
  class APIConfigurationError < StandardError; end

  class APIResponseError < StandardError

    attr_reader :message, :status
    def initialize(body)
      @message, @status = parse_error_body(body)
      super(message)
    end

    private
    def parse_error_body(body)
      if body.nil?
        ['', nil]
      elsif body[:error]
        [body[:error], body[:success]]
      end
    end
  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
cc-terminal-0.0.8 lib/terminal/errors.rb
cc-terminal-0.0.7 lib/terminal/errors.rb
cc-terminal-0.0.6 lib/terminal/errors.rb
cc-terminal-0.0.5 lib/terminal/errors.rb
cc-terminal-0.0.4 lib/terminal/errors.rb
cc-terminal-0.0.3 lib/terminal/errors.rb
cc-terminal-0.0.2 lib/terminal/errors.rb