The Win32-Kernel library provides the following utility functions.
win32-error-messageFunction
win32-error-message error-code => message
The error-code is an instance of <integer> or <machine-word> (type unioned).
The error-code argument is either a Windows a Windows error code (such as returned by GetLastError) or an SCODE (also known as an HRESULT) value (such as returned by most OLE/COM functions).
The function returns a text message (in a string) corresponding to the error code, #f if the code is not recognized. The returned string might have more than one line but does not have a newline at the end. For example:
win32-error-message(5) => "Access is denied."report-win32-error
Function
report-win32-error name #key error
NO_ERROR. If no code is specified, the value returned by the Win32 API GetLastError is used. The error that is signaled includes both the error code and the error message, as computed by the function win32-error-message.
Function
check-win32-result name result
#f or NULL to mean failure. The function check-win32-result checks the result to see if it indicates failure, and if so it calls report-win32-error. For example,
check-win32-result("SetWindowText", SetWindowText(handle, label))
ensure-no-win32-error
Function
ensure-no-win32-error name
GetLastError does not indicate that an error occurred. If an occurs, it is signaled using report-win32-error.