class Subordinate::Error
Attributes
response[RW]
Public Class Methods
from(response)
click to toggle source
# File lib/subordinate/error.rb, line 6 def self.from(response) status = response.status if klass = case status when 400 then Subordinate::BadRequest when 401 then Subordinate::Unauthorized when 404 then Subordinate::NotFound when 422 then Subordinate::UnprocessableEntity when 500 then Subordinate::InternalServerError end klass.new(response) end end
new(response)
click to toggle source
Calls superclass method
# File lib/subordinate/error.rb, line 21 def initialize(response) @response = response super(error_message) end
Private Instance Methods
error_message()
click to toggle source
# File lib/subordinate/error.rb, line 27 def error_message message = "#{response.env[:method].upcase} " message << "#{response.env[:url].to_s} | " message << "#{response.status} " message end