Class: Routemaster::Middleware::ErrorHandling
- Inherits:
-
Faraday::Response::Middleware
- Object
- Faraday::Response::Middleware
- Routemaster::Middleware::ErrorHandling
- Defined in:
- lib/routemaster/middleware/error_handling.rb
Constant Summary collapse
- ERRORS_MAPPING =
{ (400..400) => Errors::InvalidResource, (401..401) => Errors::UnauthorizedResourceAccess, (403..403) => Errors::UnauthorizedResourceAccess, (404..404) => Errors::ResourceNotFound, (405..405) => Errors::MethodNotAllowed, (409..409) => Errors::ConflictResource, (410..410) => Errors::ResourceGone, (412..412) => Errors::IncompatibleVersion, (413..413) => Errors::InvalidResource, (429..429) => Errors::ResourceThrottling, (407..500) => Errors::FatalResource, (503..503) => Errors::ServiceNotAvailable }.freeze
Instance Method Summary collapse
Instance Method Details
#on_complete(env) ⇒ Object
22 23 24 25 26 27 28 |
# File 'lib/routemaster/middleware/error_handling.rb', line 22 def on_complete(env) ERRORS_MAPPING.each do |range, error_class| if range.include?(env[:status]) raise error_class.new(env) end end end |