Skip to content

Commit 1e4f161

Browse files
authored
Merge pull request rails#50538 from sato11/rescue-responses-docs
Resolve documentational ambiguity over `rescue_responses` [ci-skip]
2 parents 6c0f5f6 + 75dbe78 commit 1e4f161

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)