Module: LastError

Defined in:
lib/vr/sysmod.rb

Constant Summary collapse

GetLastError =

LastError

This is for handling LastError.

Class Methods

— set(ecode)

Sets lasterror code as ((|ecode|)).

— code — get

Gets last error code.

— code2msg(ecode,msgarg=0)

Get the error message of ((|ecode|)). 
((|msgarg|)) is optional argument for message formatting.

— message(arg=0)

Returns last error message.
Win32API.new('kernel32','GetLastError','V','L')
SetLastError =
Win32API.new('kernel32','SetLastError','L','V')
FormatMessage =
Win32API.new('kernel32','FormatMessageA','LPLLPLP','L')
FORMAT_MESSAGE_FROM_SYSTEM =
4096

Class Method Summary collapse

Class Method Details

.codeObject



229
230
231
# File 'lib/vr/sysmod.rb', line 229

def self.code
  GetLastError.call()
end

.code2msg(scode, msg = 0) ⇒ Object



234
235
236
237
238
239
# File 'lib/vr/sysmod.rb', line 234

def self.code2msg(scode,msg=0)
  buffer = " "*(2048)
  len = FormatMessage.call FORMAT_MESSAGE_FROM_SYSTEM,0,scode,0,
                           buffer,buffer.size,msg
  buffer[0,len]
end

.getObject



232
# File 'lib/vr/sysmod.rb', line 232

def self.get() self.code end

.message(msg = 0) ⇒ Object



241
242
243
# File 'lib/vr/sysmod.rb', line 241

def self.message(msg=0)
  self.code2msg(self.code,msg)
end

.set(ecode) ⇒ Object



225
226
227
# File 'lib/vr/sysmod.rb', line 225

def self.set(ecode)
  SetLastError.call(ecode)
end