Class: Rails::API::PublicExceptions
- Inherits:
-
Object
- Object
- Rails::API::PublicExceptions
- Defined in:
- lib/rails-api/public_exceptions.rb
Instance Attribute Summary collapse
-
#public_path ⇒ Object
Returns the value of attribute public_path.
Instance Method Summary collapse
- #call(env) ⇒ Object
-
#initialize(public_path) ⇒ PublicExceptions
constructor
A new instance of PublicExceptions.
Constructor Details
#initialize(public_path) ⇒ PublicExceptions
Returns a new instance of PublicExceptions.
6 7 8 |
# File 'lib/rails-api/public_exceptions.rb', line 6 def initialize(public_path) @public_path = public_path end |
Instance Attribute Details
#public_path ⇒ Object
Returns the value of attribute public_path.
4 5 6 |
# File 'lib/rails-api/public_exceptions.rb', line 4 def public_path @public_path end |
Instance Method Details
#call(env) ⇒ Object
10 11 12 13 14 15 16 17 18 |
# File 'lib/rails-api/public_exceptions.rb', line 10 def call(env) exception = env["action_dispatch.exception"] status = env["PATH_INFO"][1..-1] request = ActionDispatch::Request.new(env) content_type = request.formats.first body = { :status => status, :error => exception. } render(status, content_type, body) end |