Skip to content

Commit

Permalink
Merge pull request rails#50538 from sato11/rescue-responses-docs
Browse files Browse the repository at this point in the history
Resolve documentational ambiguity over `rescue_responses` [ci-skip]
  • Loading branch information
rafaelfranca authored Jan 2, 2024
2 parents 6c0f5f6 + 75dbe78 commit 1e4f161
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions guides/source/configuring.md
Original file line number Diff line number Diff line change
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 1e4f161

Please sign in to comment.