Skip to content

Commit 8a2fcda

Browse files
committed
replace deprecated rack_response with error!
1 parent f8f343b commit 8a2fcda

File tree

1 file changed

+7
-7
lines changed

1 file changed

+7
-7
lines changed

lib/slack-ruby-bot-server/api/helpers/error_helpers.rb

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -10,42 +10,42 @@ module ErrorHelpers
1010
Middleware.logger.error "#{e.class.name}: #{e.message}\n #{backtrace}"
1111
error = { type: 'other_error', message: e.message }
1212
error[:backtrace] = backtrace
13-
rack_response(error.to_json, 400)
13+
error!(error, 400)
1414
end
1515
# rescue document validation errors into detail json
1616
if SlackRubyBotServer::Config.mongoid?
1717
rescue_from Mongoid::Errors::Validations do |e|
1818
backtrace = e.backtrace[0..5].join("\n ")
1919
Middleware.logger.warn "#{e.class.name}: #{e.message}\n #{backtrace}"
20-
rack_response({
20+
error!({
2121
type: 'param_error',
2222
message: e.document.errors.full_messages.uniq.join(', ') + '.',
2323
detail: e.document.errors.messages.each_with_object({}) do |(k, v), h|
2424
h[k] = v.uniq
2525
end
26-
}.to_json, 400)
26+
}, 400)
2727
end
2828
end
2929
rescue_from Grape::Exceptions::Validation do |e|
3030
backtrace = e.backtrace[0..5].join("\n ")
3131
Middleware.logger.warn "#{e.class.name}: #{e.message}\n #{backtrace}"
32-
rack_response({
32+
error!({
3333
type: 'param_error',
3434
message: 'Invalid parameters.',
3535
detail: { e.params.join(', ') => [e.message] }
36-
}.to_json, 400)
36+
}, 400)
3737
end
3838
rescue_from Grape::Exceptions::ValidationErrors do |e|
3939
backtrace = e.backtrace[0..5].join("\n ")
4040
Middleware.logger.warn "#{e.class.name}: #{e.message}\n #{backtrace}"
41-
rack_response({
41+
error!({
4242
type: 'param_error',
4343
message: 'Invalid parameters.',
4444
detail: e.errors.each_with_object({}) do |(k, v), h|
4545
# JSON does not permit having a key of type Array
4646
h[k.count == 1 ? k.first : k.join(', ')] = v
4747
end
48-
}.to_json, 400)
48+
}, 400)
4949
end
5050
end
5151
end

0 commit comments

Comments
 (0)