CHttpServer::GetLastError Method  
 
DWORD GetLastError(
  LPTSTR lpszError,  
  INT nMaxLength  
);
DWORD GetLastError(
  CString& strError  
);
DWORD GetLastError();

Return the last server error code and a description of the error.

Parameters

lpszError
A pointer to a string buffer that will contain a description of the error. If the error description is not needed, this parameter may be NULL. An alternate version of this method accepts a CString object if it is available.
nMaxLength
An integer that specifies the maximum number of characters that can be copied into the error string buffer, including the terminating null character. If the lpszError parameter is NULL, this value should be zero.

Return Value

An unsigned integer value that specifies the last error that occurred. A value of zero indicates that there was no error.

Remarks

Error codes are unsigned 32-bit values which are private to each server. You should call the GetLastError method immediately when a method's return value indicates that an error has occurred. That is because some methods clear the last error code when they succeed.

It is important to note that the error codes returned by this method are different than the command result codes that are defined in RFC 2616, the standard protocol specification for HTTP. This method is used to determine reason that an API function has failed, and should not be used to determine if a command issued by the client was successful. The SendResponse method is used to send responses to the client, and the GetCommandResult method can be used to determine the result of the last command sent by the client.

Most methods will set the last error code value when they fail; a few methods set it when they succeed. Failure is typically indicated by a return value such as FALSE, NULL, INVALID_SERVER or HTTP_ERROR. Those methods which clear the last error code when they succeed are noted on their reference page.

Requirements

Minimum Desktop Platform: Windows 7 Service Pack 1
Minimum Server Platform: Windows Server 2008 R2 Service Pack 1
Header File: cstools11.h
Import Library: cshtsv11.lib
Unicode: Implemented as Unicode and ANSI versions

See Also

GetCommandResult, SendResponse, SetLastError