Sha256: 0796b99f999a037e6cd6d5521862d575c637df6eb4e81818a0d6ef4e6f172850
Contents?: true
Size: 758 Bytes
Versions: 2
Compression:
Stored size: 758 Bytes
Contents
# frozen_string_literal: true module Aikido module Errors AikidoError = Class.new(StandardError) # Represents an error that occurred while making an API request. class ApiError < AikidoError def initialize(response) @response = response super("API Error: #{response.status}") end def message json = @response.json if json.key?('error_description') "#{super} - #{json['error_description']}" elsif json.key?('reason_phrase') "#{super} - #{json['reason_phrase']}" else super end end end BadRequestError = Class.new(ApiError) UnauthorizedError = Class.new(ApiError) NotFoundError = Class.new(ApiError) end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
aikido-ruby-client-0.0.4 | lib/aikido/errors.rb |
aikido-ruby-client-0.0.3 | lib/aikido/errors.rb |