Esempio n. 1
0
        protected override void OnIncomingError(ExceptionContext exceptionContext, IHubIncomingInvokerContext invokerContext)
        {
            Console.WriteLine(exceptionContext.Error);

            //exceptionContext.Result = "Change the return value, nulls error";
            base.OnIncomingError(exceptionContext, invokerContext);
        }
        /// <summary>
        /// Wraps a function that invokes a server-side hub method. Even if a client has not been authorized to connect
        /// to a hub, it will still be authorized to invoke server-side methods on that hub unless it is prevented in
        /// <see cref="IHubPipelineModule.BuildIncoming"/> by not executing the invoke parameter.
        /// </summary>
        /// <param name="invoke">A function that invokes a server-side hub method.</param>
        /// <returns>A wrapped function that invokes a server-side hub method.</returns>
        public virtual Func<IHubIncomingInvokerContext, Task<object>> BuildIncoming(Func<IHubIncomingInvokerContext, Task<object>> invoke)
        {
            return async context =>
            {
                if (OnBeforeIncoming(context))
                {
                    try
                    {
                        var result = await invoke(context).OrEmpty().PreserveCulture();
                        return OnAfterIncoming(result, context);
                    }
                    catch (Exception ex)
                    {
                        var exContext = new ExceptionContext(ex);
                        OnIncomingError(exContext, context);

                        var error = exContext.Error;
                        if (error == ex)
                        {
                            throw;
                        }
                        else if (error != null)
                        {
                            throw error;
                        }
                        else
                        {
                            return exContext.Result;
                        }
                    }
                }

                return null;
            };
        }
 protected override void OnIncomingError(ExceptionContext exceptionContext, IHubIncomingInvokerContext context)
 {
     if (log.IsErrorEnabled)
     {
         log.ErrorFormat("Exception while invoking {0} on hub {1}: {2}", context.MethodDescriptor.Name, context.MethodDescriptor.Hub.Name, exceptionContext.Error.Message);
     }
     base.OnIncomingError(exceptionContext, context);
 }
 protected override void OnIncomingError(ExceptionContext exceptionContext, IHubIncomingInvokerContext invokerContext)
 {
     ChatLog.Debug("=> Exception " + exceptionContext.Error.Message + " " + exceptionContext.Error.StackTrace);
     if (exceptionContext.Error.InnerException != null)
     {
         ChatLog.Debug("=> Inner Exception " + exceptionContext.Error.InnerException.Message + " " + exceptionContext.Error.InnerException.StackTrace);
     }
     base.OnIncomingError(exceptionContext, invokerContext);
 }
Esempio n. 5
0
 protected override void OnIncomingError(ExceptionContext exceptionContext, IHubIncomingInvokerContext invokerContext)
 {
     Debug.WriteLine("=> Exception " + exceptionContext.Error.Message);
     if (exceptionContext.Error.InnerException != null)
     {
         Debug.WriteLine("=> Inner Exception " + exceptionContext.Error.InnerException.Message);
     }
     base.OnIncomingError(exceptionContext, invokerContext);
 }
 protected override void OnIncomingError(ExceptionContext ex, IHubIncomingInvokerContext context)
 {
     _slabLogger.Log(HubType.HubServerVerbose, "=> Exception " + ex.Error + " " + ex.Result);
     if (ex.Error.InnerException != null)
     {
         _slabLogger.Log(HubType.HubServerVerbose, "=> Inner Exception " + ex.Error.InnerException.Message);
     }
     base.OnIncomingError(ex, context);
 }
 protected override void OnIncomingError(ExceptionContext exceptionContext, IHubIncomingInvokerContext invokerContext) {
     _logger.Error()
         .Exception(exceptionContext.Error)
         .MarkUnhandled("ErrorHandlingPipelineModule")
         .Message("Unhandled: {0}", exceptionContext.Error.Message)
         .Tag("SignalR")
         .Write();
     
     base.OnIncomingError(exceptionContext, invokerContext);
 }
 protected override void OnIncomingError(ExceptionContext exceptionContext, IHubIncomingInvokerContext invokerContext)
 {
     try
     {
         Log.Error(exceptionContext.Error, "Exception invoking {Method} on {Hub} with {Args}", invokerContext.MethodDescriptor.Name, invokerContext.Hub.GetType().Name, invokerContext.Args);
     }
     // ReSharper disable once UnusedVariable
     catch (Exception e)
     {
         if (Debugger.IsAttached) Debugger.Break();
     }
 }
        protected override void OnIncomingError(ExceptionContext exceptionContext, IHubIncomingInvokerContext invokerContext)
        {
            string message = string.Format("=> Exception {0}", exceptionContext.Error.Message);

            if (exceptionContext.Error.InnerException != null)
            {
                message += "\n\t=> Inner Exception " + exceptionContext.Error.InnerException.Message;
            }

            WindowsEventLog.WriteErrorLog(message);

            base.OnIncomingError(exceptionContext, invokerContext);
        }
    protected override void OnIncomingError(ExceptionContext exceptionContext,
        IHubIncomingInvokerContext invokerContext)
    {

      Log.Error("Error accessing hub " + exceptionContext.Error.Message, this);


      if (exceptionContext.Error.InnerException != null)
      {
        Log.Error("=> Inner Exception " + exceptionContext.Error.InnerException.Message, this);
      }

      base.OnIncomingError(exceptionContext, invokerContext);

    }
Esempio n. 11
0
 protected override void OnIncomingError(ExceptionContext exceptionContext,
                                         IHubIncomingInvokerContext invokerContext)
 {
     Trace.Fail("HUB EXCEPTION: " + exceptionContext.Error.Message);
     dynamic caller = invokerContext.Hub.Clients.Caller;
     caller.ExceptionHandler(exceptionContext.Error.Message);
 }
        protected override void OnIncomingError(ExceptionContext exceptionContext, IHubIncomingInvokerContext invokerContext)
        {
            Logger.Error(exceptionContext.Error);

            base.OnIncomingError(exceptionContext, invokerContext);
        }
Esempio n. 13
0
 protected override void OnIncomingError(ExceptionContext exceptionContext, IHubIncomingInvokerContext invokerContext)
 {
     exceptionContext.Result = 42;
 }
Esempio n. 14
0
 //参考:http://www.asp.net/signalr/overview/guide-to-the-api/hubs-api-guide-server#singleusergroups
 protected override void OnIncomingError(ExceptionContext ex, IHubIncomingInvokerContext invokerContext)
 {
     string connectionId = invokerContext.Hub.Context.ConnectionId;
     invokerContext.Hub.Clients.Caller.ShowError(string.Format("ConnectionId:{0},ErrorMessage:{1}", connectionId, ex.Error.Message));
 }
Esempio n. 15
0
 protected override void OnIncomingError(ExceptionContext exceptionContext, IHubIncomingInvokerContext context)
 {
     _logger.LogError("{0}: Failure while invoking '{1}'.", context.Hub.Context.Request.User.GetUserId(), context.MethodDescriptor.Name);
     _logger.Log(exceptionContext.Error);
 }
Esempio n. 16
0
 protected override void OnIncomingError(ExceptionContext exceptionContext, IHubIncomingInvokerContext invokerContext)
 {
     exceptionContext.Error = new HubException("Wrapped", new { Error = "Data" });
 }
        /// <summary>
        /// This is called when an uncaught exception is thrown by a server-side hub method or the incoming component of a
        /// module added later to the <see cref="IHubPipeline"/>. Observing the exception using this method will not prevent
        /// it from bubbling up to other modules.
        /// </summary>
        /// <param name="exceptionContext">
        /// Represents the exception that was thrown during the server-side invocation.
        /// It is possible to change the error or set a result using this context.
        /// </param>
        /// <param name="invokerContext">A description of the server-side hub method invocation.</param>
        protected virtual void OnIncomingError(ExceptionContext exceptionContext, IHubIncomingInvokerContext invokerContext)
        {

        }
 protected override void OnIncomingError(Microsoft.AspNet.SignalR.Hubs.ExceptionContext exceptionContext, IHubIncomingInvokerContext invokerContext)
 {
     Trace.WriteLine("@signalr Err" + exceptionContext.Error.ToString());
     base.OnIncomingError(exceptionContext, invokerContext);
 }
 protected override void OnIncomingError(ExceptionContext exceptionContext, IHubIncomingInvokerContext invokerContext)
 {
     string connectionId = invokerContext.Hub.Context.ConnectionId;
     Exception ex = exceptionContext.Error.InnerException ?? exceptionContext.Error;
     invokerContext.Hub.Clients.Caller.ExceptionHandler(ex);
 }
 protected override void OnIncomingError(ExceptionContext exceptionContext, IHubIncomingInvokerContext invokerContext)
 {
     Debug.Write(" = > 错误:" + exceptionContext.Error);
     base.OnIncomingError(exceptionContext, invokerContext);
 }