Ejemplo n.º 1
0
        public MyException(string message, SqlException sqlException) : base(message, sqlException)
        {
            switch (sqlException.Number)
            {
            case (int)MyErrorType.ConcurrencyObjectDelete:
                _typError = MyErrorType.ConcurrencyObjectDelete;
                break;

            case (int)MyErrorType.DatabaseObjectMissing:
                _typError = MyErrorType.DatabaseObjectMissing;
                MyExceptionManager.Log(this);
                break;

            case (int)MyErrorType.DatabaseNoConnection:
            case (int)MyErrorType.DatabaseNoConnection1:
                _typError = MyErrorType.DatabaseNoConnection;
                MyExceptionManager.Log(this);
                break;

            case (int)MyErrorType.DatabaseConnectionLost:
                _typError = MyErrorType.DatabaseConnectionLost;
                MyExceptionManager.Log(this);
                break;

            case (int)MyErrorType.ConstraintUnique:
                _typError = MyErrorType.ConstraintUnique;
                break;

            default:
                _typError = MyErrorType.Unhandled;
                MyExceptionManager.Log(this);
                break;
            }
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Permanently deletes a stored template.
        /// </summary>
        /// <param name="templatePath">The full path of a stored template file.</param>
        /// <returns>true if the template was deleted; otherwise false.</returns>
        public static bool DeleteTemplate(string templatePath)
        {
            bool rtnValue = false;

            if (File.Exists(templatePath))
            {
                try
                {
                    File.Delete(templatePath);
                    rtnValue = true;
                }
                catch (Exception ex)
                {
                    MyExceptionManager.Log(ex);
                    return(false);
                }
            }

            return(rtnValue);
        }
        /// <summary>
        ///
        /// This method is the event handler for any unhandled exceptions in the application.
        /// If it catches any of these errors, it will display the error, log it, and then exit.
        /// It is hooked in Main.
        ///
        /// </summary>
        /// <param name="sender" type="object">not used.</param>
        /// <param name="t" type="ThreadExceptionEventArgs">the exception thrown.</param>
        public static void HandleApplicationException(object sender, ThreadExceptionEventArgs t)
        {
            try
            {
                frmError frm = new frmError(MyExceptionManager.Log(t.Exception));

                if (frm.ShowDialog() == DialogResult.Cancel)
                {
                    Environment.Exit(0);
                }
            }
            catch
            {
                try
                {
                    MyMessageBox.Show(null, "Fatal Error", MyDisplayMessage.FatalError);
                }
                finally
                {
                    Environment.Exit(0);
                }
            }
        }