// Set the error code only if there is an error (i.e. nativeError >= 0). Otherwise the code ----s up on deserialization // as the Exception..ctor() throws on setting HResult to 0. The default for HResult is -2147467259. private void SetErrorCodeOnError(int nativeError) { if (!WebSocketProtocolComponent.Succeeded(nativeError)) { this.HResult = nativeError; } }
/// <summary>Creates an instance of the <see cref="T:System.Net.WebSockets.WebSocketException" /> class.</summary> /// <param name="nativeError">The native error code for the exception.</param> /// <param name="innerException">Indicates the previous exception that led to the current exception.</param> public WebSocketException(int nativeError, Exception innerException) : base(SR.GetString("net_WebSockets_Generic"), innerException) { this.m_WebSocketErrorCode = !WebSocketProtocolComponent.Succeeded(nativeError) ? WebSocketError.NativeError : WebSocketError.Success; this.SetErrorCodeOnError(nativeError); }
/// <summary>Creates an instance of the <see cref="T:System.Net.WebSockets.WebSocketException" /> class.</summary> /// <param name="nativeError">The native error code for the exception.</param> /// <param name="message">The description of the error.</param> public WebSocketException(int nativeError, string message) : base(nativeError, message) { this.m_WebSocketErrorCode = !WebSocketProtocolComponent.Succeeded(nativeError) ? WebSocketError.NativeError : WebSocketError.Success; this.SetErrorCodeOnError(nativeError); }