Skip to content

Commit 75dbe78

Browse files
committed
Resolve documentational ambiguity over rescue_responses [ci-skip]
The issue was raised years ago at rails#27128 where everyone involved agreed that the documentation should be worked on, only to leave it forgotten. I believe it is still relevant as the ambiguity remains ever since. Also, two of exceptions which have a seat in the current default have been missing in the documentation so this commit aligns them.
1 parent 361f296 commit 75dbe78

File tree

1 file changed

+11
-2
lines changed

1 file changed

+11
-2
lines changed

guides/source/configuring.md

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1948,16 +1948,25 @@ information. It defaults to `true`.
19481948

19491949
#### `config.action_dispatch.rescue_responses`
19501950

1951-
Configures what exceptions are assigned to an HTTP status. It accepts a hash and you can specify pairs of exception/status. By default, this is defined as:
1951+
Configures what exceptions are assigned to an HTTP status. It accepts a hash and you can specify pairs of exception/status.
19521952

19531953
```ruby
1954-
config.action_dispatch.rescue_responses = {
1954+
# It's good to use #[]= or #merge! to respect the default values
1955+
config.action_dispatch.rescue_responses['MyAuthenticationError'] = :unauthorized
1956+
```
1957+
1958+
Use `ActionDispatch::ExceptionWrapper.rescue_responses` to observe the configuration. By default, it is defined as:
1959+
1960+
```ruby
1961+
{
19551962
'ActionController::RoutingError' => :not_found,
19561963
'AbstractController::ActionNotFound' => :not_found,
19571964
'ActionController::MethodNotAllowed' => :method_not_allowed,
19581965
'ActionController::UnknownHttpMethod' => :method_not_allowed,
19591966
'ActionController::NotImplemented' => :not_implemented,
19601967
'ActionController::UnknownFormat' => :not_acceptable,
1968+
'ActionDispatch::Http::MimeNegotiation::InvalidType' => :not_acceptable,
1969+
'ActionController::MissingExactTemplate' => :not_acceptable,
19611970
'ActionController::InvalidAuthenticityToken' => :unprocessable_entity,
19621971
'ActionController::InvalidCrossOriginRequest' => :unprocessable_entity,
19631972
'ActionDispatch::Http::Parameters::ParseError' => :bad_request,

0 commit comments

Comments
 (0)