Next Previous Up Top Contents Index

2 The Functional Developer Win32 API Libraries

2.6 Error messages

The Win32-Kernel library provides the following utility functions.

win32-error-message

Function

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

Signals a Dylan error if the Win 32 error code specified is not 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.
check-win32-result

Function

check-win32-result name result

Many Windows functions return #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

Ensures that the Win32 API GetLastError does not indicate that an error occurred. If an occurs, it is signaled using report-win32-error.

C FFI and Win 32 Reference - 31 MAR 2000

Next Previous Up Top Contents Index