Module: Outreach::Errors
- Included in:
- Request
- Defined in:
- lib/outreach-ruby/errors.rb
Defined Under Namespace
Classes: Unauthorized
Constant Summary collapse
- UNAUTHORIZED_ID =
'unauthenticatedRequest'.freeze
Instance Method Summary collapse
Instance Method Details
#check_for_error(_status_code, response_body) ⇒ Object
6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 |
# File 'lib/outreach-ruby/errors.rb', line 6 def check_for_error(_status_code, response_body) response_hash = JSON.parse(response_body) errors = [] if !response_hash['errors'].nil? && response_hash['errors'].any? errors = response_hash['errors'].map { |error| create_error_hash(error) } end errors.map do |error| case error[:id] when UNAUTHORIZED_ID raise , error[:detail] else raise StandardError, error[:title] + ': ' + error[:detail] end end end |