class Vhx::Middleware::ErrorResponse
Public Instance Methods
on_complete(env)
click to toggle source
# File lib/vhx/middleware/error_response.rb, line 4 def on_complete(env) error_class = case env[:status] when 200, 201, 204 when 304 when 400 BadRequestError when 401 if env[:body].fetch('message', '').match(/token/) InvalidTokenError else UnauthorizedError end when 402 PaymentRequiredError when 404 NotFoundError when 406 NotAcceptableError else ServerError end if error_class raise error_class.new(env[:body], env[:status], env[:url]) end end