Sha256: 126c51fb4e6cc29022fbef8912aebdb81b1222d2e633e514bf7c26486e6bbeea

Contents?: true

Size: 1.26 KB

Versions: 86

Compression:

Stored size: 1.26 KB

Contents

# frozen-string-literal: true

module Sequel
  module Plugins
    # The empty_failure_backtraces plugin uses empty backtraces when raising HookFailed and ValidationFailed
    # exceptions.  This can be significantly faster, and if you are using these exceptions for
    # flow control, you do not need the backtraces.  This plugin is about 10% faster on CRuby
    # and 10-15x faster on JRuby 9.2.7.0+.  This does not have an effect on JRuby <9.2.7.0.
    #
    # Usage:
    #
    #   # Make all model subclass instances use empty backtraces for HookFailed
    #   # and ValidationFailed exceptions (called before loading subclasses)
    #   Sequel::Model.plugin :empty_failure_backtraces
    #
    #   # Make the Album class use empty backtraces for HookFailed and ValidationFailed exceptions
    #   Album.plugin :empty_failure_backtraces
    module EmptyFailureBacktraces
      module InstanceMethods
        private

        # Use empty backtrace for HookFailed exceptions.
        def hook_failed_error(msg)
          e = super
          e.set_backtrace([])
          e
        end

        # Use empty backtrace for ValidationFailed exceptions.
        def validation_failed_error
          e = super
          e.set_backtrace([])
          e
        end
      end
    end
  end
end

Version data entries

86 entries across 74 versions & 2 rubygems

Version Path
sequel-5.88.0 lib/sequel/plugins/empty_failure_backtraces.rb
sequel-5.87.0 lib/sequel/plugins/empty_failure_backtraces.rb
sequel-5.86.0 lib/sequel/plugins/empty_failure_backtraces.rb
sequel-5.85.0 lib/sequel/plugins/empty_failure_backtraces.rb
sequel-5.84.0 lib/sequel/plugins/empty_failure_backtraces.rb
sequel-5.83.1 lib/sequel/plugins/empty_failure_backtraces.rb
sequel-5.83.0 lib/sequel/plugins/empty_failure_backtraces.rb
sequel-5.82.0 lib/sequel/plugins/empty_failure_backtraces.rb
sequel-5.81.0 lib/sequel/plugins/empty_failure_backtraces.rb
sequel-5.80.0 lib/sequel/plugins/empty_failure_backtraces.rb
sequel-5.79.0 lib/sequel/plugins/empty_failure_backtraces.rb
sequel-5.78.0 lib/sequel/plugins/empty_failure_backtraces.rb
sequel-5.77.0 lib/sequel/plugins/empty_failure_backtraces.rb
sequel-5.76.0 lib/sequel/plugins/empty_failure_backtraces.rb
sequel-5.75.0 lib/sequel/plugins/empty_failure_backtraces.rb
sequel-5.74.0 lib/sequel/plugins/empty_failure_backtraces.rb
sequel-5.73.0 lib/sequel/plugins/empty_failure_backtraces.rb
sequel-5.72.0 lib/sequel/plugins/empty_failure_backtraces.rb
sequel-5.71.0 lib/sequel/plugins/empty_failure_backtraces.rb
sequel-5.70.0 lib/sequel/plugins/empty_failure_backtraces.rb