Commit e7dfbe7a23aee1c4fd224b8f72ab955eecd66f06
Committed by
GitHub
Exists in
master
Merge pull request #3 from lessonly/spenceralan/ch20833/scim-gem-fix-error-handler
fix error rescuing
Showing
3 changed files
with
18 additions
and
15 deletions
Show diff stats
Gemfile.lock
app/controllers/concerns/scim_rails/exception_handler.rb
@@ -12,6 +12,22 @@ module ScimRails | @@ -12,6 +12,22 @@ module ScimRails | ||
12 | end | 12 | end |
13 | 13 | ||
14 | included do | 14 | included do |
15 | + # StandardError must be ordered _first_ or it will catch all exceptions | ||
16 | + # | ||
17 | + # TODO: Build a plugin/configuration for error handling so that the | ||
18 | + # detailed production errors are logged somewhere if desired. | ||
19 | + if Rails.env.production? | ||
20 | + rescue_from StandardError do | ||
21 | + json_response( | ||
22 | + { | ||
23 | + schemas: ["urn:ietf:params:scim:api:messages:2.0:Error"], | ||
24 | + status: "500" | ||
25 | + }, | ||
26 | + :internal_server_error | ||
27 | + ) | ||
28 | + end | ||
29 | + end | ||
30 | + | ||
15 | rescue_from ScimRails::ExceptionHandler::InvalidCredentials do | 31 | rescue_from ScimRails::ExceptionHandler::InvalidCredentials do |
16 | json_response( | 32 | json_response( |
17 | { | 33 | { |
@@ -79,19 +95,6 @@ module ScimRails | @@ -79,19 +95,6 @@ module ScimRails | ||
79 | ) | 95 | ) |
80 | end | 96 | end |
81 | end | 97 | end |
82 | - | ||
83 | - ## StandardError must be ordered last or it will catch all exceptions | ||
84 | - if Rails.env.production? | ||
85 | - rescue_from StandardError do | ||
86 | - json_response( | ||
87 | - { | ||
88 | - schemas: ["urn:ietf:params:scim:api:messages:2.0:Error"], | ||
89 | - status: "500" | ||
90 | - }, | ||
91 | - :internal_server_error | ||
92 | - ) | ||
93 | - end | ||
94 | - end | ||
95 | end | 98 | end |
96 | end | 99 | end |
97 | end | 100 | end |
lib/scim_rails/version.rb