Method: Aggkit::ChildProcess::Windows::Lib.last_error_message

Defined in:
lib/aggkit/childprocess/windows/lib.rb

.last_error_messageObject



275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
# File 'lib/aggkit/childprocess/windows/lib.rb', line 275

def last_error_message
  errnum = FFI.errno

  buf = FFI::MemoryPointer.new :char, 512

  size = format_message(
    FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_ARGUMENT_ARRAY,
    nil, errnum, 0, buf, buf.size, nil
  )

  str = buf.read_string(size).strip
  if errnum == 0
    "Unknown error (Windows says #{str.inspect}, but it did not.)"
  else
    "#{str} (#{errnum})"
  end
end