diff --git a/CHANGELOG.md b/CHANGELOG.md index 2600df968..85f64896c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -83,6 +83,7 @@ * [#3018](https://github.com/ruby-grape/grape/pull/3018): Stop copying the auth middleware per request - [@ericproulx](https://github.com/ericproulx). * [#3023](https://github.com/ruby-grape/grape/pull/3023): Raise from `error!` instead of throwing `:error`, so a transaction it leaves rolls back - [@ericproulx](https://github.com/ericproulx). * [#3027](https://github.com/ruby-grape/grape/pull/3027): Scrub outside input through one helper, `Grape::Util::Scrub` - [@ericproulx](https://github.com/ericproulx). +* [#3030](https://github.com/ruby-grape/grape/pull/3030): Restore the Error middleware's two defaults without restating every option - [@ericproulx](https://github.com/ericproulx). * Your contribution here. ### 4.0.1 (2026-09-15) diff --git a/lib/grape/middleware/error.rb b/lib/grape/middleware/error.rb index 9f6d3e906..4da451da5 100644 --- a/lib/grape/middleware/error.rb +++ b/lib/grape/middleware/error.rb @@ -24,16 +24,12 @@ def initialize( # `Endpoint#error_middleware_options` when the API called no # `rescue_from` and no `format` — and an explicit nil bypasses the # keyword defaults above, so restore them here rather than letting nil - # propagate to `def_delegator :rescue_options, :backtrace` or to the - # formatter lookup in `#format_message`. - super( - rescue_options: rescue_options || Grape::DSL::RescueOptions.new, - default_error_formatter: default_error_formatter || Grape::ErrorFormatter::Txt, - all_rescue_handler:, base_only_rescue_handlers:, content_types:, - default_message:, default_status:, error_formatters:, format:, - grape_exceptions_rescue_handler:, internal_grape_exceptions_rescue_handler:, - rescue_all:, rescue_grape_exceptions:, rescue_handlers: - ) + # reach `rescue_options.backtrace` in `#initialize` or the formatter + # lookup in `#format_message`. A bare `super` hands the parameters + # over as they stand, these two included. + rescue_options ||= Grape::DSL::RescueOptions.new + default_error_formatter ||= Grape::ErrorFormatter::Txt + super end end