-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Passing status to the ErrorFormatter #2528
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -2772,8 +2772,8 @@ Custom error formatters for existing and additional types can be defined with a | |
|
|
||
| ```ruby | ||
| class Twitter::API < Grape::API | ||
| error_formatter :txt, ->(message, backtrace, options, env, original_exception) { | ||
| "error: #{message} from #{backtrace}" | ||
| error_formatter :txt, ->(message, backtrace, options, env, original_exception, status) { | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Is this a breaking change? Meaning if I had the old code and upgrade Grape, will this fail with an invalid number of parameters?
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Best I could tell this calls
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Since we document custom middleware this would be a breaking change :( |
||
| "error: #{message} status: #{status} from #{backtrace}" | ||
| } | ||
| end | ||
| ``` | ||
|
|
@@ -2782,8 +2782,8 @@ You can also use a module or class. | |
|
|
||
| ```ruby | ||
| module CustomFormatter | ||
| def self.call(message, backtrace, options, env, original_exception) | ||
| { message: message, backtrace: backtrace } | ||
| def self.call(message, backtrace, options, env, original_exception, status) | ||
| { message: message, status: status, backtrace: backtrace } | ||
| end | ||
| end | ||
|
|
||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -4,7 +4,7 @@ module Grape | |
| module ErrorFormatter | ||
| class Base | ||
| class << self | ||
| def call(message, backtrace, options = {}, env = nil, original_exception = nil) | ||
| def call(message, backtrace, options = {}, env = nil, original_exception = nil, _status = nil) # rubocop:disable Metrics/ParameterLists | ||
|
||
| merge_backtrace = backtrace.present? && options.dig(:rescue_options, :backtrace) | ||
| merge_original_exception = original_exception && options.dig(:rescue_options, :original_exception) | ||
|
|
||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.