File: controller_methods.rb

package info (click to toggle)
ruby-sentry-rails 5.28.0-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 300 kB
  • sloc: ruby: 1,849; makefile: 7; sh: 4
file content (28 lines) | stat: -rw-r--r-- 600 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
# frozen_string_literal: true

module Sentry
  module Rails
    module ControllerMethods
      def capture_message(message, options = {})
        with_request_scope do
          Sentry::Rails.capture_message(message, **options)
        end
      end

      def capture_exception(exception, options = {})
        with_request_scope do
          Sentry::Rails.capture_exception(exception, **options)
        end
      end

      private

      def with_request_scope
        Sentry.with_scope do |scope|
          scope.set_rack_env(request.env)
          yield
        end
      end
    end
  end
end