Example #1
0
        public void LogError(Exception exception) {
            LastError = "Error trying to process manifest.";
            if (exception == null)
                return;

            LogMessages.Add(String.Concat(DateTime.UtcNow.ToShortDateString(), " - ", exception.ToString()));
            LastError = exception.GetAllMessages();
        }
Example #2
0
		public static void LogException(Action<string> logger, Exception e, bool addSystemInfo, string msg, params object[] format)
		{
			if (!string.IsNullOrEmpty(msg))
			{
				msg = string.Format(msg, format);
				logger(msg);
			}

			if (e != null)
			{
				LogStacktrace(logger);
				logger("");
				logger(e.ToString());
				//logger(new StackTrace(e, true));
			}

			if (addSystemInfo)
			{
				logger("");
				SystemInfoLogger(logger);
			}

			if (e != null)
			{
				logger("");
				logger(e.GetAllMessages().ToString("\n\t"));
			}

			var evt = ExceptionRaised;
			if (evt != null)
			{
				evt(msg, e);
			}
		}
Example #3
0
 protected override void OnCommandFail(WCell.Util.Commands.CmdTrigger<Squishy.Irc.Commands.IrcCmdArgs> trigger, Exception ex)
 {
     CommandHandler.Msg(Properties.Settings.Default.ErrorChannel, "Exception Occured: " + ex.InnerException.Message);
     foreach (string text in ex.GetAllMessages())
         CommandHandler.Msg(Properties.Settings.Default.ErrorChannel, text);
 }
        public void ExtensionMethods_GetAllMessages_WhenUnrollingException_ExpectFullExceptionList()
        {
            //------------Setup for test--------------------------
            var innerException = new Exception("Inner Exception");
            var ex = new Exception("Test Error", innerException);
            const string expected = "Test Error\r\nInner Exception";

            //------------Execute Test---------------------------
            var result = ex.GetAllMessages();

            //------------Assert Results-------------------------
            StringAssert.Contains(result, expected);
        }
Example #5
0
		public static void OnDBError(Exception e, string warning)
		{
			try
			{
				// probably a production system - Don't drop.
				if (DBErrorHook != null && !DBErrorHook(e))
				{
					throw e;
				}
			}
			catch (Exception ex)
			{
				log.ErrorException("", ex);
			}

			var errMsg = "Database Error occured";
			LogUtil.ErrorException(e, false, errMsg);
			log.Warn("");
			foreach (var msg in e.GetAllMessages())
			{
				log.Warn(msg);
			}
			log.Warn("");
			log.Warn("Database could not be initialized!");
			log.Warn("Re-create Database schema? (y/n)");
			log.Warn("WARNING: " + warning);

			IsWaiting = true;
			bool doDrop;
			try
			{
				doDrop = StringStream.GetBool(Input.Read());
			}
			catch
			{
				// no Console available (running Tests etc)
				doDrop = true;
			}
			IsWaiting = false;

			if (doDrop)
			{
				log.Warn("Dropping database schema...");
				DropSchema();
				log.Warn("Done.");

				log.Warn("Re-creating database schema...");
				try
				{
					CreateSchema();
				}
				catch (Exception ex)
				{
					// damn it! No console output...
					throw new InvalidOperationException("", ex);
				}
				log.Warn("Done.");
			}
			else
			{
				throw new InvalidOperationException("", e);
			}
		}
Example #6
0
 public static void Error(string group, Exception exception)
 {
     var message = $"[Error Text]{exception.GetAllMessages()}\r\n[Error Full]{exception}";
     _logger.Log(group, message);
 }