/// <summary> /// Takes an exception and serializes the important information and sends it to the recipient connection. /// </summary> /// <param name="serialization">Serialization information to use for this response.</param> /// <param name="ex">Exception which occurred to send to the recipient session.</param> /// <param name="messageReturnId">Id used to reference this call on the recipient session.</param> private void SendRpcException(SerializationCache.Serializer serialization, Exception ex, ushort messageReturnId) { // Reset the length of the stream to clear it. serialization.Stream.SetLength(0); // Clear the message writer of any previously stored data. serialization.MessageWriter.Clear(); // Writer the Rpc call type and the return Id. serialization.MessageWriter.Write(messageReturnId); // Get the exception information in a format that we can serialize. var exception = new RpcRemoteExceptionDataContract(ex is TargetInvocationException ? ex.InnerException : ex); // Serialize the class with a length prefix. serialization.SerializeToWriter(exception, 0); // Send the message to the recipient connection. SendHandlerMessage((byte)RpcCallMessageAction.MethodException, serialization.MessageWriter.ToMessage(true)); }
/// <summary> /// Creates instance of the remote exception class. /// </summary> /// <param name="exception">Exception details which are used to pass along to the base exception.</param> public RpcRemoteException(RpcRemoteExceptionDataContract exception) : base(exception.Message) { }