class NHKProgram::Response::RaiseError
@private
Public Instance Methods
on_complete(env)
click to toggle source
# File lib/nhk_program/response/raise_error.rb, line 11 def on_complete(env) case env[:status].to_i when 400 raise NHKProgram::BadRequest, error_message(env) when 401 raise NHKProgram::NotAuthorized, error_message(env) when 403 raise NHKProgram::Forbidden, error_message(env) when 404 raise NHKProgram::NotFound, error_message(env) when 400...500 raise NHKProgram::ClientError, error_message(env) when 500 raise NHKProgram::InternalServerError, error_message(env) when 503 raise NHKProgram::ServiceUnavailable, error_message(env) when 500...600 raise NHKProgram::ServerError, error_message(env) end end
Private Instance Methods
error_message(env)
click to toggle source
# File lib/nhk_program/response/raise_error.rb, line 34 def error_message(env) body = env[:body] if body.nil? nil elsif body['error'] && body['error']['message'] body['error']['message'] elsif body['fault'] && body['fault']['faultstring'] body['fault']['faultstring'] end end