Sha256: f87ee4f5c54e5079f0820c61d44de42381a92087cdefc32608599ac8b3524b5e

Contents?: true

Size: 1.19 KB

Versions: 4

Compression:

Stored size: 1.19 KB

Contents

module ProjectlockerErrata
  module Rails
    module ErrorLookup

      # Sets up an alias chain to catch exceptions when Rails does
      def self.included(base) #:nodoc:
        base.send(:alias_method, :rescue_action_locally_without_projectlocker_errata, :rescue_action_locally)
        base.send(:alias_method, :rescue_action_locally, :rescue_action_locally_with_projectlocker_errata)
      end

      private

      def rescue_action_locally_with_projectlocker_errata(exception)
        result = rescue_action_locally_without_projectlocker_errata(exception)

        if ProjectlockerErrata.configuration.development_lookup
          path   = File.join(File.dirname(__FILE__), '..', '..', 'templates', 'rescue.erb')
          notice = ProjectlockerErrata.build_lookup_hash_for(exception, projectlocker_errata_request_data)

          result << @template.render(
            :file          => path,
            :use_full_path => false,
            :locals        => { :host    => ProjectlockerErrata.configuration.host,
                                :api_key => ProjectlockerErrata.configuration.api_key,
                                :notice  => notice })
        end

        result
      end
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
projectlocker_errata-0.1.1 lib/projectlocker_errata/rails/error_lookup.rb
projectlocker_errata-0.1.0 lib/projectlocker_errata/rails/error_lookup.rb
projectlocker_errata-0.0.2 lib/projectlocker_errata/rails/error_lookup.rb
projectlocker_errata-0.0.1 lib/projectlocker_errata/rails/error_lookup.rb