SendError Method  
 

Send a result code and message to the client in response to a command.

Syntax

object.SendError( ClientId, ErrorCode, [Message] )

Parameters

ClientId
An integer that identifies the client session.
ErrorCode
An integer value that specifies the error code that should be sent to the client. This value should correspond to the error result codes defined for HTTP in RFC 2616, which are three-digit values in the range of 400 through 599. The function will fail if an invalid error code is specified.
Message
An optional string value that specifies a message to be sent to the client. If this parameter is omitted is an empty string, a default message associated with the result code will be used.

Return Value

A value of zero is returned if the response was sent to the client. Otherwise, a non-zero error code is returned which indicates the cause of the failure.

Remarks

The SendError method sends a response to the client indicating that an error has occurred, providing a numeric error code and HTML formatted text which may be displayed to the user. The Message parameter should provide a brief description of the error that will be included in the output sent to the client. Note that the message should not contain any special formatting control characters or HTML markup.

This method provides a simplified interface for sending an error response to the client. In some cases, a browser may choose to display its own error message to the user in place of the generic HTML document generated by this method. If you want your application to send a customized HTML document for a specific type of error, you should use the SendResponse method.

If you wish to redirect the client to use an alternate URL to access the requested resource, it is recommended that you use the RedirectRequest method rather than sending an error response.

See Also

RedirectRequest Method, SendResponse Method, OnCommand Event, OnResult Event