Exception: PerfectReach::ApiError

Inherits:
StandardError
  • Object
show all
Defined in:
lib/perfect_reach/api_error.rb

Instance Method Summary collapse

Constructor Details

#initialize(code, res, request, request_path, params) ⇒ ApiError

Returns a new instance of ApiError.



6
7
8
9
10
11
12
13
14
15
16
17
# File 'lib/perfect_reach/api_error.rb', line 6

def initialize(code, res, request, request_path, params)
	# code is ugly, output is pretty
	super("error #{code} while sending #{request.inspect} to #{request_path} with #{params.inspect}\n\n" +
				(res['errors'].present? ?
					[(res['errors'] || [])].flatten.map do |param, text|
						[param, text].map(&:to_s).reject(&:blank?).join(': ')
					end.join("\n") :
					res.inspect
				) +
				"\n\nPlease see http://api.perfect-reach.com for more informations on error numbers.\n\n"
	)
end