Sha256: 39d2b34e0d12f1076844769c20a32e48cc2cec716cbcbbb4bc6940ab4982da2a

Contents?: true

Size: 658 Bytes

Versions: 2

Compression:

Stored size: 658 Bytes

Contents

module Safemode
  class Error < RuntimeError; end

  class SecurityError < Error
    @@types = { :const => 'constant',
                :xstr  => 'shell command',
                :fcall => 'method',
                :vcall => 'method',
                :gvar  => 'global variable' }

    def initialize(type, value = nil)
      type = @@types[type] if @@types.include?(type)
      super "Safemode doesn't allow to access '#{type}'" + (value ? " on #{value}" : '')
    end
  end

  class NoMethodError < Error
    def initialize(method, jail, source = nil)
      super "undefined method '#{method}' for #{jail}" + (source ? " (#{source})" : '')
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
safemode-1.5.0 lib/safemode/exceptions.rb
safemode-1.4.0 lib/safemode/exceptions.rb