Sha256: eb8c304096469c499b840ab04eab5aa7a65304d275850e564893710ec369950e

Contents?: true

Size: 1.12 KB

Versions: 41

Compression:

Stored size: 1.12 KB

Contents

require 'singleton'

module Immunio
  # General agent error
  class Error < RuntimeError; end

  # Error to block a request in progress
  # Ruby's `SecurityError` is outside the `StandardError` hierarchy, so it will
  # only be caught if somebody decides to catch it explicitly.
  #
  # `StandardError` and `RuntimeError` are both caught by a default rescue
  # block. This makes it too easy for a developer to catch and ignore one of
  # our blocking errors unintentionally.
  class BlockError < SecurityError; end

  # Request was not allowed by hook
  class RequestBlocked < BlockError
    class Result
      include Singleton

      # PG activerecord exception results must have an error_field method before Rails 4.x
      def error_field(_field)
        ""
      end
    end

    # PG activerecord exceptions must have a result method before Rails 4.x
    def result
      Result.instance
    end
  end

  # Response overridden by hook
  class OverrideResponse < BlockError
    attr_reader :status, :headers, :body

    def initialize(status, headers, body)
      @status = status
      @headers = headers
      @body = body
    end
  end
end

Version data entries

41 entries across 41 versions & 1 rubygems

Version Path
immunio-2.0.4 lib/immunio/errors.rb
immunio-2.0.3 lib/immunio/errors.rb
immunio-2.0.2 lib/immunio/errors.rb
immunio-1.2.1 lib/immunio/errors.rb
immunio-1.1.19 lib/immunio/errors.rb
immunio-1.1.18 lib/immunio/errors.rb
immunio-1.1.16 lib/immunio/errors.rb
immunio-1.1.15 lib/immunio/errors.rb
immunio-1.1.13 lib/immunio/errors.rb
immunio-1.1.11 lib/immunio/errors.rb
immunio-1.1.10 lib/immunio/errors.rb
immunio-1.1.7 lib/immunio/errors.rb
immunio-1.1.6 lib/immunio/errors.rb
immunio-1.1.5 lib/immunio/errors.rb
immunio-1.1.2 lib/immunio/errors.rb
immunio-1.1.1 lib/immunio/errors.rb
immunio-1.1.0 lib/immunio/errors.rb
immunio-1.0.22 lib/immunio/errors.rb
immunio-1.0.19 lib/immunio/errors.rb
immunio-1.0.17 lib/immunio/errors.rb