Custom middleware block throws backtrace exception

I need some advice. I am working on my first Rack middleware. However, when an exception occurs from, say, the controller, I don’t get the full exception, since my middleware, apparently the latter has a hand on it:

NoMethodError (undefined method `accessible?' for "zFhY3ksiR4UdtGH3ZHs3":String):
   app/middleware/content_negotiation.rb:28:in `_call'
   app/middleware/content_negotiation.rb:20:in `call'

Instead of a real backtrace, for example:

[ 0] "/.../lib/doorkeeper/doorkeeper_for.rb:17:in `validate_token'",
[ 1] "/.../lib/doorkeeper/helpers/filter.rb:9:in `block in doorkeeper_for'",

Line 20 of the user middleware corresponds to:

 def call(env)
  dup._call(env)
 end

Line 28 corresponds to this line _call:

status, headers, response = @app.call(env)

What is the best practice for transparent / non-blocking user middleware in this case? Should I get rid of this middleware and show an exception / reverse trace?

Thank.

+4
1

http://api.rubyonrails.org/classes/ActiveSupport/BacktraceCleaner.html

config/initializers/backtrace_silencers.rb

, .

Rails.backtrace_cleaner.add_silencer { |line| line =~ /app\/middleware/ }
0

Source: https://habr.com/ru/post/1537060/


All Articles