class Cha::Middleware::RaiseError
@private
Public Instance Methods
on_complete(env)
click to toggle source
# File lib/cha/middleware.rb, line 37 def on_complete(env) case env[:status].to_i when 400 raise BadRequest, error_message(env) when 401 raise NotAuthorized, error_message(env) when 403 raise Forbidden, error_message(env) when 404 raise NotFound, error_message(env) when 400...500 raise ClientError, error_message(env) when 500 raise InternalServerError, error_message(env) when 501 raise NotImplemented, error_message(env) when 503 raise ServiceUnavailable, error_message(env) when 500...600 raise ServerError, error_message(env) end end
Private Instance Methods
error_message(env)
click to toggle source
# File lib/cha/middleware.rb, line 62 def error_message(env) body = env[:body] if body.nil? nil elsif body['errors'] body['errors'].join(', ') end end