/// <summary> /// Creates a <see cref="RpcErrorMessage"/> based on the specified <see cref="SocketError"/>. /// </summary> /// <param name="socketError">The underlying <see cref="SocketError"/>.</param> /// <returns> /// A <see cref="RpcErrorMessage"/> based on the specified <see cref="SocketError"/>. /// </returns> public static RpcErrorMessage ToClientRpcError(this SocketError socketError) { if (socketError.IsError().GetValueOrDefault()) { return(new RpcErrorMessage(socketError.ToRpcError(), new SocketException((int)socketError).Message, string.Empty)); } else { return(RpcErrorMessage.Success); } }
/// <summary> /// Gets the <see cref="RpcErrorMessage"/> corresponds to the specified <see cref="SocketError"/>. /// </summary> /// <param name="socketError">The <see cref="SocketError"/>.</param> /// <returns> /// The <see cref="RpcErrorMessage"/> corresponds to the specified <see cref="SocketError"/>. /// </returns> public static RpcErrorMessage ToServerRpcError(this SocketError socketError) { if (socketError.IsError().GetValueOrDefault()) { RpcError rpcError = socketError.ToRpcError(); return(new RpcErrorMessage(rpcError, rpcError == RpcError.TransportError ? "Unexpected socket error." : rpcError.DefaultMessageInvariant, new SocketException(( int )socketError).Message)); } else { return(RpcErrorMessage.Success); } }