Sha256: 79588531a11990bffb0cf9557506d96725528188273b98a6f5bbaf6b4667306d

Contents?: true

Size: 876 Bytes

Versions: 4

Compression:

Stored size: 876 Bytes

Contents

module Sandbox
  
  class Error < StandardError
    
    def initialize( msg=nil )
      super msg
    end
    
    def message
      out = []
      value = super
      out << "Sandbox error: #{value}"
      out.concat( backtrace.collect { |bt| "    #{bt}" } ) if Sandbox.really_verbose?
      out.join( "\n" )
    end
    
  end
  
  class LoadedSandboxError < Sandbox::Error
    
    def initialize( msg=nil )
      msg ||= "You cannot run sandbox from a loaded sandbox environment"
      super msg
    end
    
  end
  
  class ParseError < Sandbox::Error
    
    def initialize( reason=nil, args=[] )
      if args.is_a?( Array ) and args.size > 0
        msg = "#{reason} => #{args.join( ' ' )}"
      elsif args.is_a?( String ) and args.length > 0
        msg = "#{reason} => #{args}"
      else
        msg = reason
      end
      super msg
    end
    
  end
  
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
nkryptic-sandbox-0.2.1 lib/sandbox/errors.rb
nkryptic-sandbox-0.2.2 lib/sandbox/errors.rb
nkryptic-sandbox-0.2.3 lib/sandbox/errors.rb
nkryptic-sandbox-0.2.4 lib/sandbox/errors.rb