Example #1
0
        /// <summary>
        /// Call this if something unexpected happened.
        /// </summary>
        /// <param name="x">summary text</param>
        /// <param name="msg">message text</param>
        public static void Panic(string sender, PanicType ptype, string msg)
        {
            if (panicLevel.HasFlag(PanicLevel.Silent))
            {
                return;
            }

            string message = $"{ptype}\t{sender}:\t{msg}";

            if (panicLevel.HasFlag(PanicLevel.File))
            {
                File.AppendAllText(logpath, $"{DateTime.Now}\t{message}\r\n");
            }

            if (panicLevel.HasFlag(PanicLevel.Console))
            {
                Console.WriteLine(message);

                if (panicLevel.HasFlag(PanicLevel.Pause))
                {
                    Console.ReadKey();
                }
            }

            if (panicLevel.HasFlag(PanicLevel.Exception) && ptype.HasFlag(PanicType.Error))
            {
                throw new Exception(message);
            }
        }
Example #2
0
 /// <summary>
 /// Call this if something unexpected happened.
 /// </summary>
 /// <param name="x">the object that wants to panic</param>
 /// <param name="msg">the message it wants to send</param>
 public static void Panic(object x, PanicType ptype, string msg)
 {
     Panic(x.GetType().Name, ptype, msg);
 }