Exemplo n.º 1
0
        public void errorWriter(MySqlException oMySQLException)
        {
            TheLogger.Log("ExecSql Error in " + oMySQLException.TargetSite + " due to : " + oMySQLException.Message + "\n");
            string errorText = oMySQLException.ToString();

            errorWriter(errorText);
        }
Exemplo n.º 2
0
 //Everything that goes wrong with MySql will raise an MySqlException. Since this is also used in connectToDb() the query is optional.
 public void HandleException(MySqlException exception, string query = "")
 {
     Console.WriteLine("!!EXCEPTION THROWN: \n" + exception.ToString());
     if (query.Length != 0)
     {
         Console.WriteLine("Query executed: " + query);
     }
 }
Exemplo n.º 3
0
        /// <summary>
        /// Brings up a window with the given error.
        /// </summary>
        /// <param name="error">Error.</param>
        void errorHandle(MySqlException error)
        {
            NSAlert oAlert = new NSAlert();

            // Set the buttons
            oAlert.InvokeOnMainThread(delegate
            {
                oAlert.AddButton("Ok");
            });
            // Show the message box and capture
            oAlert.MessageText     = "There's a problem with the query!";
            oAlert.InformativeText = error.ToString();
            oAlert.AlertStyle      = NSAlertStyle.Informational;
        }
Exemplo n.º 4
0
        //
        // WriteToEventLog
        //   A helper function that writes exception detail to the event log. Exceptions
        // are written to the event log as a security measure to avoid private database
        // details from being returned to the browser. If a method does not return a status
        // or boolean indicating the action succeeded or failed, a generic exception is also
        // thrown by the caller.
        //
        private void WriteToEventLog(MySqlException e, string action)
        {
            using (EventLog log = new EventLog())
            {
                log.Source = eventSource;
                log.Log    = eventLog;

                string message = exceptionMessage + "\n\n";
                message += Resources.LocalizedText.LogAction + action + "\n\n";
                message += Resources.LocalizedText.LogException + e.ToString();

                log.WriteEntry(message);
            }
        }
Exemplo n.º 5
0
        //
        // WriteToEventLog
        //   A helper function that writes exception detail to the event log. Exceptions
        // are written to the event log as a security measure to avoid private database
        // details from being returned to the browser. If a method does not return a status
        // or boolean indicating the action succeeded or failed, a generic exception is also
        // thrown by the caller.
        //

        private void WriteToEventLog(MySqlException e, string action)
        {
            EventLog log = new EventLog();

            log.Source = eventSource;
            log.Log    = eventLog;

            string message = exceptionMessage + "\n\n";

            message += "Action: " + action + "\n\n";
            message += "Exception: " + e.ToString();

            log.WriteEntry(message);
        }
Exemplo n.º 6
0
        /// <summary>
        /// Handles MySql exception.
        /// If WriteExceptionsToEventLog is set, will write exception info
        /// to event log.
        /// It throws provider exception (original exception is stored as inner exception)
        /// </summary>
        /// <param name="e">exception</param>
        /// <param name="action"> name of the function that throwed the exception</param>
        private void HandleMySqlException(MySqlException e, string action)
        {
            if (WriteExceptionsToEventLog)
            {
                using (EventLog log = new EventLog())
                {
                    log.Source = eventSource;
                    log.Log    = eventLog;

                    string message = "An exception occurred communicating with the data source.\n\n";
                    message += "Action: " + action;
                    message += "Exception: " + e.ToString();
                    log.WriteEntry(message);
                }
            }
            throw new ProviderException(exceptionMessage, e);
        }
Exemplo n.º 7
0
        public static Exception GenerarDesdeMySqlException(MySqlException ex)
        {
            switch (ex.Number)
            {
            case 1042:
                return(new SinConexionException(ex));

            case 1062:
                return(new ElementoDuplicadoException(ex));

            case 1451:
                return(new NoSePuedeEliminarException("porque existe una referencia.", ex));

            default:
                Console.WriteLine(ex.Number);
                Console.WriteLine(ex.ToString( ));
                return(null);
            }
        }
Exemplo n.º 8
0
 public void NoDatabaseConnection(MySqlException ex)
 {
     MessageBox.Show("No connection to Database\nAppliction will be closed\n" + ex.ToString());
     this.Close();
 }
Exemplo n.º 9
0
        public void SQLError(MySqlException ex)
        {
            switch (ex.ErrorCode)
            {
            case 0:
                SMain.Enqueue(string.Format("Cannot connect to MySQL Database :\tIP : {0}\tPort : {1}\tDatabase : {2}", Settings.SQL_IP, Settings.SQL_PORT, Settings.SQL_DBName));
                break;

            case 1045:
                SMain.Enqueue(string.Format("Login failure for MySQL Database, check details!"));
                break;

            case 1053:
                SMain.Enqueue(string.Format("MySQL Server is shutting down.."));
                break;

            case 1054:
                SMain.Enqueue(string.Format("MySQL Column not found in table."));
                break;

            case 1055:
                SMain.Enqueue(string.Format("MySQL Item isn't in GROUP BY."));
                break;

            case 1056:
                SMain.Enqueue(string.Format("MySQL Cannot GROUP BY on table."));
                break;

            case 1059:
                SMain.Enqueue(string.Format("MySQL Identifier name is too long."));
                break;

            case 1060:
                SMain.Enqueue(string.Format("MySQL Column duplicate in statement."));
                break;

            case 1061:
                SMain.Enqueue(string.Format("MySQL Key Name duplicate in statement."));
                break;

            case 1062:
                SMain.Enqueue(string.Format("MySQL Duplicate entry for key in statement."));
                break;

            case 1063:
                SMain.Enqueue(string.Format("MySQL Incorrect column specifier."));
                break;

            case 1065:
                SMain.Enqueue(string.Format("MySQL Empty Query."));
                break;

            case 1077:
                SMain.Enqueue(string.Format("MySQL Shutting down.."));
                break;

            case 1078:
                SMain.Enqueue(string.Format("MySQL Aborting : Reason receive Signal."));
                break;

            case 1079:
                SMain.Enqueue(string.Format("MySQL Shutdown complete."));
                break;

            case 1102:
                SMain.Enqueue(string.Format("MySQL Incorrect database name."));
                break;

            case 1105:
                SMain.Enqueue("MySQL Unknown Error.");
                break;

            case 1146:
                SMain.Enqueue(string.Format("Table does not exist on MySQL Database."));
                break;

            default:
                SMain.Enqueue(string.Format("MySQL insert characterinfo data error : {0}", ex.ToString()));
                break;
            }
        }
Exemplo n.º 10
0
 /// <summary>
 /// Gestion des erreurs
 /// Envoie un message dans une console
 /// </summary>
 /// <param name="ex">MySqlException</param>
 private void gestionErr(MySqlException ex)
 {
     Console.WriteLine("Error: {0}", ex.ToString());
     Console.WriteLine("Press enter to close...");
     Console.ReadLine();
 }