Skip to content

Commit

Permalink
Resolve documentational ambiguity over rescue_responses [ci-skip]
Browse files Browse the repository at this point in the history
The issue was raised years ago at #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.
  • Loading branch information
sato11 committed Jan 2, 2024
1 parent 361f296 commit 75dbe78
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions guides/source/configuring.md
Expand Up @@ -1948,16 +1948,25 @@ information. It defaults to `true`.

#### `config.action_dispatch.rescue_responses`

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:
Configures what exceptions are assigned to an HTTP status. It accepts a hash and you can specify pairs of exception/status.

```ruby
config.action_dispatch.rescue_responses = {
# It's good to use #[]= or #merge! to respect the default values
config.action_dispatch.rescue_responses['MyAuthenticationError'] = :unauthorized
```

Use `ActionDispatch::ExceptionWrapper.rescue_responses` to observe the configuration. By default, it is defined as:

```ruby
{
'ActionController::RoutingError' => :not_found,
'AbstractController::ActionNotFound' => :not_found,
'ActionController::MethodNotAllowed' => :method_not_allowed,
'ActionController::UnknownHttpMethod' => :method_not_allowed,
'ActionController::NotImplemented' => :not_implemented,
'ActionController::UnknownFormat' => :not_acceptable,
'ActionDispatch::Http::MimeNegotiation::InvalidType' => :not_acceptable,
'ActionController::MissingExactTemplate' => :not_acceptable,
'ActionController::InvalidAuthenticityToken' => :unprocessable_entity,
'ActionController::InvalidCrossOriginRequest' => :unprocessable_entity,
'ActionDispatch::Http::Parameters::ParseError' => :bad_request,
Expand Down

0 comments on commit 75dbe78

Please sign in to comment.