コード例 #1
0
        private async Task WriteRpcExceptionToResponse(HttpContext context, WebRpcCallFailedException rpcException)
        {
            Guid guid;

            Guid.TryParse(context.Request.Headers[HeaderNames.Tracking], out guid);

            if (guid == Guid.Empty)
            {
                Guid.TryParse(context.Request.Headers[HeaderNames.Corrolation], out guid);
            }

            var envelope = new RemoteExceptionInfo()
            {
                CorrelationId  = guid,
                Message        = rpcException.RemoteException.Message,
                Type           = rpcException.RemoteException.Type,
                StackTrace     = rpcException.RemoteException.StackTrace,
                Source         = rpcException.RemoteException.Source,
                ExceptionId    = rpcException.RemoteException.ExceptionId,
                MachineName    = rpcException.RemoteException.MachineName,
                InnerException = rpcException.RemoteException.InnerException
            };

            await WriteExceptionEnvelopeToResponse(context, envelope);

            WriteToLog(rpcException);
        }
コード例 #2
0
        private async Task WriteExceptionToResponse(HttpContext context, Exception ex)
        {
            Guid guid;

            Guid.TryParse(context.Request.Headers[HeaderNames.Tracking], out guid);

            if (guid == Guid.Empty)
            {
                Guid.TryParse(context.Request.Headers[HeaderNames.Corrolation], out guid);
            }

            var envelope = new RemoteExceptionInfo
            {
                CorrelationId  = guid,
                Message        = ex.Message,
                Type           = ex.GetType().AssemblyQualifiedName,
                StackTrace     = ex.StackTrace,
                Source         = ex.Source,
                ExceptionId    = Guid.NewGuid(),
                MachineName    = container.MachineName,
                InnerException = ex.InnerException
            };

            await WriteExceptionEnvelopeToResponse(context, envelope);

            WriteToLog(ex);
        }
コード例 #3
0
        private Task WriteExceptionEnvelopeToResponse(HttpContext context, RemoteExceptionInfo env)
        {
            context.Response.StatusCode  = 500;
            context.Response.ContentType = "application/json";
            container.Serializer.ToStream(context.Response.Body, env);

            return(context.Response.Body.FlushAsync());
        }