From 4a2c641b28bb388bd1bb496b9c3243f34ecd7a11 Mon Sep 17 00:00:00 2001 From: Wendel Fabian Chinsamy Date: Wed, 20 Nov 2024 17:25:36 +0200 Subject: [PATCH] add middleware error logging --- lib/middleware/compressed_requests.rb | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/lib/middleware/compressed_requests.rb b/lib/middleware/compressed_requests.rb index 02ffbf541..7b23a99c3 100644 --- a/lib/middleware/compressed_requests.rb +++ b/lib/middleware/compressed_requests.rb @@ -28,8 +28,14 @@ def call(env) env["rack.input"] = StringIO.new(extracted) end - status, headers, response = @app.call(env) - [status, headers, response] + begin + status, headers, response = @app.call(env) + [status, headers, response] + rescue => err + Raven.capture_exception(err) + Rails.logger.error(err.inspect) + [500, {}, [{ "status": 400, "title": err.message }.to_json]] + end end def decode(input, content_encoding)