NGWS SDK Documentation  

This is preliminary documentation and subject to change.
To comment on this topic, please send us email at ngwssdk@microsoft.com. Thanks!

Error Handling

The WebRequest and WebResponse classes throw both system exceptions (such as InvalidArgumentException) and Web specific exceptions in the WebException class.

Each WebException includes a Status property that contains a value from WebStatus. You can examine the Status property to determine the error that occurred and take the proper steps to resolve the error. The possible values for the Status property are:

Status Value Description
Success 0 No error was encountered.
Error -1 General error status.
NameResolutionFailure -2 The name resolver service could not resolve the host name.
ConnectFailure -3 The remote service could not be contacted at the transport level.
ReceiveFailure -4 A complete response was not received from the remote server.
SendFailure -5 A complete request could not be sent to the remote server.
ResponseTimeout -6 No response was received within the timeout settings in the Connection class.
RequestCanceled -7 The request was canceled.
ProtocolError -8 Thre response received from the server was complete but indicated an error at the protocol level.
ConnectionClosed -9 The connection was prematurely closed.
TrustFailure -10 A server certificate could not be validated.
SecureChannelFailure -11 An error occurred in a secure channel link.

When the Status property is WebStatus.ProtocolError, a WebResponse is available that contains the response from the server. This response an be examined to determine the actual source of the protocol error.

Applications that use the Socket class must handle any error codes returned by the Socket class. These error codes are contained in the SocketErrors class. The TCPClient, TCPListener, and UDPClient classes are built on top of the Socket class, and will return SocketErrors as well.