public void HandleException(ExceptionOccuredContext context)
        {
            // todo 填充处理逻辑

            context.ContinueThrows = false;
            // 不要忘记在MahuaModule中注册
        }
        public HandlerExceptionMahuaCommandResult Handle(HandlerExceptionMahuaCommand message)
        {
            var continueThrows = true;

            foreach (var exceptionOccuredMahuaEvent in _exceptionOccuredMahuaEvents)
            {
                var exceptionOccuredContext = new ExceptionOccuredContext
                {
                    Exception      = message.Exception,
                    ContinueThrows = true,
                    SourceCommand  = message.SourceCommand,
                };
                exceptionOccuredMahuaEvent.HandleException(exceptionOccuredContext);

                // 一旦有一个处理,认为不应该抛出异常,则中断异常的抛出。
                if (!exceptionOccuredContext.ContinueThrows)
                {
                    continueThrows = false;
                }
            }
            return(new HandlerExceptionMahuaCommandResult
            {
                Exception = message.Exception,
                ContinueThrows = continueThrows
            });
        }
        public void HandleException(ExceptionOccuredContext context)
        {
            var cmd     = context.SourceCommand;
            var cmdType = cmd.GetType();

            Logger.ErrorException($"由{cmdType.Name}命令引发了异常", context.Exception);
            var cmdBytes = GlobalCache.CrossDoaminSerializer.Serialize(cmd, cmdType);
            var json     = MessagePackSerializer.ToJson(cmdBytes);

            Logger.Debug($"命令的内容为:{json}");
        }
Beispiel #4
0
        public void HandleException(ExceptionOccuredContext context)
        {
            // todo 填充处理逻辑
            if (ConfigManager.larkBotConfig == null)
            {
                _mahuaApi.SendPrivateMessage("821113542", context.Exception.ToString());
            }
            else
            {
                _mahuaApi.SendPrivateMessage(ConfigManager.larkBotConfig.AdminQQ, context.Exception.ToString());
            }

            // 不要忘记在MahuaModule中注册
        }
 public void HandleException(ExceptionOccuredContext context)
 {
     _mahuaApi.SendPrivateMessage("415206409").Text(context.Exception.ToString());
     // 不要忘记在MahuaModule中注册
 }