Beispiel #1
0
        public static void OnDBError(Exception e, string warning)
        {
            try
            {
                if (DBErrorHook != null && !DBErrorHook(e))
                {
                    throw e;
                }
            }
            catch (Exception ex)
            {
                log.ErrorException("", ex);
            }

            string msg = "Database Error occured";

            LogUtil.ErrorException(e, false, msg);
            log.Warn("");
            foreach (string allMessage in e.GetAllMessages())
            {
                log.Warn(allMessage);
            }
            log.Warn("");
            log.Warn("Database could not be initialized!");
            log.Warn("Re-create Database schema? (y/n)");
            log.Warn("WARNING: " + warning);
            IsWaiting = true;
            bool flag;

            try
            {
                flag = StringStream.GetBool(Input.Read());
            }
            catch
            {
                flag = true;
            }

            IsWaiting = false;
            if (!flag)
            {
                throw new InvalidOperationException("", e);
            }
            log.Warn("Dropping database schema...");
            DropSchema();
            log.Warn("Done.");
            log.Warn("Re-creating database schema...");
            try
            {
                CreateSchema();
            }
            catch (Exception ex)
            {
                throw new InvalidOperationException("", ex);
            }

            log.Warn("Done.");
        }
Beispiel #2
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);
            }
        }