Sha256: 3b6cf2c636fdc05c8739e71a5613355cd9424db8d36ce6bd6fdb0a2125abd479

Contents?: true

Size: 636 Bytes

Versions: 10

Compression:

Stored size: 636 Bytes

Contents

module Rescue
  module RespondError

    def self.included(base)
      Rescue::ApplicationError::STATUS_CODES.each do |code, e|
        status_code = (Rescue.config.suppress_response_codes ? 200 : e[:http])
        class_name = e[:status].gsub(' ', '')
        next if Object.const_defined?(class_name)

        exception_class = Class.new(Rescue::ApplicationError) do
          define_method :initialize do |message = nil|
            super code, e[:status], message
          end
        end
        Object.const_set class_name, exception_class
        base.rescue_associate class_name, with: status_code
      end
    end

  end
end

Version data entries

10 entries across 10 versions & 1 rubygems

Version Path
rescue-dog-0.3.9 lib/rescue/exceptions/respond_error.rb
rescue-dog-0.3.8 lib/rescue/exceptions/respond_error.rb
rescue-dog-0.3.7 lib/rescue/exceptions/respond_error.rb
rescue-dog-0.3.5 lib/rescue/exceptions/respond_error.rb
rescue-dog-0.3.4 lib/rescue/exceptions/respond_error.rb
rescue-dog-0.3.2 lib/rescue/exceptions/respond_error.rb
rescue-dog-0.3.1 lib/rescue/exceptions/respond_error.rb
rescue-dog-0.3.0 lib/rescue/exceptions/respond_error.rb
rescue-dog-0.2.1 lib/rescue/exceptions/respond_error.rb
rescue-dog-0.2.0 lib/rescue/exceptions/respond_error.rb