class Grape::Middleware::Error

def error_response(error = {})

def error_response(error = {})
  status = error[:status] || options[:default_status]
  env[Grape::Env::API_ENDPOINT].status(status) # error! may not have been called
  message = error[:message] || options[:default_message]
  headers = { Rack::CONTENT_TYPE => content_type }.tap do |h|
    h.merge!(error[:headers]) if error[:headers].is_a?(Hash)
  end
  backtrace = error[:backtrace] || error[:original_exception]&.backtrace || []
  original_exception = error.is_a?(Exception) ? error : error[:original_exception] || nil
  rack_response(status, headers, format_message(message, backtrace, original_exception))
end