Exception: PosixPsutil::AccessDenied

Inherits:
PsutilError
  • Object
show all
Defined in:
lib/posixpsutil/psutil_error.rb

Overview

Raise it when the access is denied, a wrapper of ENOENT::EACCES

Instance Method Summary collapse

Methods inherited from PsutilError

#to_s

Constructor Details

#initialize(opt = {}) ⇒ AccessDenied

Returns a new instance of AccessDenied.



33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
# File 'lib/posixpsutil/psutil_error.rb', line 33

def initialize(opt={})
  @pid = opt[:pid] || nil
  @name = opt[:name] || nil
  if opt[:msg].nil?
    if @pid && @name
      details = "(pid=#{@pid}, name=#{@name.to_s})"
    elsif @pid
      details = "(pid=#{@pid})"
    else
      details = ""
    end
    opt[:msg] = "access is denied " + details
  end
  @message = opt[:msg]
end