lessonly / scim_rails

SCIM Adapter for Rails.
MIT License
68 stars 76 forks source link

fix error rescuing #3

Closed spenceralan closed 5 years ago

spenceralan commented 5 years ago

Why?

I made an incorrect assumption about how rescue statements work! I thought by putting the catch-all rescue statement last that it would exercise only after the other rescue statements have been evaluated. This was exactly wrong. The catch-all rescue statement needed to be first because rescue statements after it are evaluated before it. Documentation here.

What?

This PR iterates the patch level version and changes the order of the rescue statements.

Testing Notes

The only way to really test this is to remove the logic that the code only execute in production and run the specs to see that they still pass.

app/controllers/concerns/scim_rails/exception_handler.rb:19

if Rails.env.production?
  rescue_from StandardError do
    json_response(
      {
        schemas: ["urn:ietf:params:scim:api:messages:2.0:Error"],
        status: "500"
      },
      :internal_server_error
    )
  end
end