Example #1
0
        private async Task HandleExceptionAsync(IDialogContext context, Exception ex, string messagePrefix)
        {
            if (ex is SignTimeoutException)
            {
                await context.SayAsync($"Sorry I timed out - please ask me to do something again.");
            }
            else
            {
                await context.SayAsync(messagePrefix + ex.Message);

                LogErrorAttribute.LogException(ex);
            }
        }
Example #2
0
        public void EnsureInitialize(Assembly assembly)
        {
            foreach (var type in assembly.GetTypes())
            {
                ExecutionContainerAttribute containerAttr =
                    type.GetCustomAttributes(typeof(ExecutionContainerAttribute), false)
                    .Cast <ExecutionContainerAttribute>()
                    .FirstOrDefault();
                if (containerAttr == null)
                {
                    continue;
                }
                LogErrorAttribute classErrorAttr = type.GetCustomAttributes(typeof(LogErrorAttribute), false).Cast <LogErrorAttribute>().FirstOrDefault();
                var factory = _factories[containerAttr.FactoryType];
                var methods = type.GetMethods(  );
                foreach (var method in methods)
                {
                    ExecutionAttribute executionAttr = method.GetCustomAttributes(typeof(ExecutionAttribute), false).Cast <ExecutionAttribute>().FirstOrDefault();
                    LogErrorAttribute  logErrorAttr  = method.GetCustomAttributes(typeof(LogErrorAttribute), false).Cast <LogErrorAttribute>().FirstOrDefault();
                    if (executionAttr != null)
                    {
                        var handle = method.MethodHandle;

                        ValueEventHandler handler = (object sender, ValueEventArgs e) => MethodBase.GetMethodFromHandle(handle).Invoke(null, new object[] { sender, e });
                        var execution             = new FuncExecution(handler);
                        if (logErrorAttr != null)
                        {
                            execution.SwallowError = logErrorAttr.Swallow;
                            execution.LogError     = true;
                        }
                        else if (classErrorAttr != null)
                        {
                            execution.SwallowError = classErrorAttr.Swallow;
                            execution.LogError     = true;
                        }
                        factory.Add(executionAttr.Key, execution);
                    }
                }
            }
        }
Example #3
0
 /// <summary>
 /// Handles application errors.
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 protected void Application_Error(object sender, System.EventArgs e)
 {
     LogErrorAttribute.Log(Server.GetLastError());
 }