```ruby
class CustomPublicExceptions < ActionDispatch::PublicExceptions
  def call(env)
    status = env["PATH_INFO"][1..-1]
    if status == "404"
      Rails.application.routes.call(env)
    else
      super
    end
  end
end
```

Add logic to our customer dispatcher to catch 500 errors in addition to 400 errors.
user
```ruby
class CustomPublicExceptions < ActionDispatch::PublicExceptions
  def call(env)
    status = env["PATH_INFO"][1..-1]

    if status == "404" || status == "500"
      Rails.application.routes.call(env)
    else
      super
    end
  end
end
```
assistant