Пример #1
0
        /// <summary>
        /// Factory method that constructs the ActorInvokeException from an exception.
        /// </summary>
        /// <param name="exception">Exception.</param>
        /// <returns>Serialized bytes.</returns>
        internal static byte[] FromException(Exception exception)
        {
            var exceptionData  = new ActorInvokeExceptionData(exception.GetType().FullName, exception.Message);
            var exceptionBytes = exceptionData.Serialize();

            return(exceptionBytes);
        }
Пример #2
0
        internal static bool TryDeserialize(Stream stream, out Exception result, ILogger logger = null)
        {
            try
            {
                stream.Seek(0, SeekOrigin.Begin);
                var eData = ActorInvokeExceptionData.Deserialize(stream);
                result = new ActorInvokeException(eData.Type, eData.Message);
                return(true);
            }
            catch (Exception e)
            {
                // swallowing the exception
                logger?.LogWarning("RemoteException", "DeSerialization failed : Reason  {0}", e);
            }

            result = null;
            return(false);
        }