Inheritance: System.Data.Common.DbException
Esempio n. 1
1
        /// <summary>
        ///   function to translate sql exceptions to readable messages. 
        ///   It also captures cases where sql server is not available and guards against
        ///   database connection details being leaked
        /// </summary>
        /// <param name = "exc"></param>
        /// <returns></returns>
        /// <remarks>
        /// </remarks>
        public static string TranslateSQLException(SqlException exc)
        {
            int i = 0;
            var errorMessages = new StringBuilder();
            for (i = 0; i <= exc.Errors.Count - 1; i++)
            {
                SqlError sqlError = exc.Errors[i];
                string filteredMessage = string.Empty;
                switch (sqlError.Number)
                {
                    case 17:
                        filteredMessage = "Sql server does not exist or access denied";
                        break;
                    case 4060:
                        filteredMessage = "Invalid Database";
                        break;
                    case 18456:
                        filteredMessage = "Sql login failed";
                        break;
                    case 1205:
                        filteredMessage = "Sql deadlock victim";
                        break;
                    default:
                        filteredMessage = exc.ToString();
                        break;
                }

                errorMessages.Append("<b>Index #:</b> " + i + "<br/>" + "<b>Source:</b> " + sqlError.Source + "<br/>" + "<b>Class:</b> " + sqlError.Class + "<br/>" + "<b>Number:</b> " +
                                     sqlError.Number + "<br/>" + "<b>Procedure:</b> " + sqlError.Procedure + "<br/>" + "<b>Message:</b> " + filteredMessage + "<br/>");
            }
            return errorMessages.ToString();
        }
Esempio n. 2
1
        /// <summary>
        /// Получить текст сообщения для исключения БД
        /// </summary>
        /// <param name="exception">Исключение БД</param>
        /// <returns>Текст сообщения</returns>
        private static string GetSqlErrorMessage(SqlException exception)
        {
            string result = Resources.SqlMessages.UnknownError;
            int errorCode = exception.Number;

            switch (errorCode)
            {
                case 2601:
                    // Duplicate key
                    result = Resources.SqlMessages.DuplicateRecord;
                    break;
                case 547:
                    // Reference/Foreign key constraint conflict
                    var match = Regex.Matches(exception.Message, @"The (\w+) .+")[0];
                    string operation = match.Groups[1].Value;
                    if (operation == "INSERT" || operation == "UPDATE")
                    {
                        result = Resources.SqlMessages.ConstraintConflict;
                    }
                    else if (operation == "DELETE")
                    {
                        result = Resources.SqlMessages.DeleteErrorConstraint;
                    }
                    break;
                case 8152:
                    // String or binary data would be truncated
                    result = Resources.SqlMessages.TooLongString;
                    break;
            }

            return result;
        }
Esempio n. 3
0
        private static string[] ParseSQLException(SqlException ex)
        {
            string errField, errMessage;

            switch (ex.Number)
            {
                case 2601:
                case 2627:
                    {
                        char[] splited = { '"', '“', '”' };
                        string[] msg = ex.Message.Split(splited);
                        if (msg.Length <= 2)
                        {
                            errField = null;
                            errMessage = ex.Message;
                        }
                        else
                        {
                            errField = msg[1];
                            errMessage = string.Format("Value of '{0}' exists, can not insert the same value.", errField);
                        }
                    }
                    break;
                default:
                    {
                        errField = null;
                        errMessage = ex.Message;
                    }
                    break;
            }

            return new string[2] { errField, errMessage };
        }
        public static string mostrarError(string strDescripcion, System.Exception objError)
        {
            string strMensaje = strDescripcion + "\n\n";

            switch (objError.GetType().ToString())
            {
            case "System.Data.SqlClient.SqlException":
                System.Data.SqlClient.SqlException nuevoError = (System.Data.SqlClient.SqlException)objError;
                switch (nuevoError.Number)
                {
//					case 547:
//						strMensaje += "Denegado. El sistema ha detectado elementos relacionados con el registro seleccionado.";
//						break;
                case 2627:
                    strMensaje += "Denegado. El sistema ha detectado que intenta insertar un elemento duplicado.";
                    break;

                default:
                    strMensaje += "Error: " + nuevoError.Message;
                    break;
                }
                break;

            default:
                strMensaje += "Error: " + objError.Message;
                break;
            }
            strMensaje = strMensaje.Replace("\n", @"\n");
            strMensaje = strMensaje.Replace("\r", @"\n");

            return(strMensaje);
        }
Esempio n. 5
0
 /// <summary>
 /// Adds the given SqlException's message to the general error logger.
 /// </summary>
 /// <param name="except">The sql exception storing the message that gets passed to the logger</param>
 protected void AddExceptToError(SqlException except)
 {
     if (except.Number == -2 || except.Number == 0)
     {
         GeneralLogger.GetInstance().AddError(except.Message);
     }
 }
Esempio n. 6
0
    public static string CheckExp(SqlException ex)
    {
        switch (ex.Number)
        {
            case 2627:
                return "موجود مسبقاً ...";
            case 233:
                return "SQl Server غير متاح";
            case 2:
                return "SQl Server غير متاح";
            case 515:
                string ReturnMe = "يجب مليء" + Environment.NewLine;
                int tempint = 0;
                foreach (char Chr in ex.Message.ToCharArray())
                {
                    //Get column name from error msg and its between ''
                    char Dot = '\'';

                    if (Chr == Dot)
                        tempint++;
                    if (tempint == 1)
                        ReturnMe += Chr;
                    else if (tempint == 2)
                        break;
                }
                return ReturnMe + "'";
            default:
                return "خطاء في بيانات الادخال";
        }
    }
Esempio n. 7
0
    protected void grid_RowDeleting(object sender, GridViewDeleteEventArgs e)
    {
        try
        {
            DataManager.Parameters.Add(DataParameterKeyName, grid.DataKeys[e.RowIndex].Value);
            DataManager.Parameters.Add("@CompanyId", Company.CompanyId);

            DataManager.ExecuteNonQuery("DELETE FROM " + TableName + " WHERE " + DataKeyName + " = " + DataParameterKeyName +
                                        " AND CompanyId = @CompanyId");

            DataManager.Commit();
        }
        catch (Exception ex)
        {
            if (ex.GetBaseException() is System.Data.SqlClient.SqlException)
            {
                System.Data.SqlClient.SqlException err = ex as System.Data.SqlClient.SqlException;
                if (err.ErrorCode.Equals(Convert.ToInt32("0x80131904", 16)))
                {
                    ShowError(Resources.Exception.DeletingRegisterWithForeignKey);
                }
            }
        }
        CarregaGrid(-1);
    }
Esempio n. 8
0
        private string GetUserFriendlyMessage(Exception e)
        {
            string msg = "";

            if (e.GetType() == typeof(HttpUnhandledException))
            {
                msg = e.Message;
            }
            else if (e.GetType() == typeof(System.Data.SqlClient.SqlException))
            {
                System.Data.SqlClient.SqlException sEx = (System.Data.SqlClient.SqlException)e;
                foreach (SqlError se in sEx.Errors)
                {
                    if (se.Number >= 50000)
                    {
                        // these should be custom errors thrown - do the lookup
                        msg = "SQL Error";
                    }
                }
                if (string.IsNullOrEmpty(msg))
                {
                    msg = "SQL Error";
                }
            }
            else
            {
                msg = "SQL Error";
            }
            return(msg);
        }
Esempio n. 9
0
        public static string CheckExp(SqlException ex)
        {
            switch (ex.Number)
            {
                case 2627:
                    return "Already Exist ...";
                case 233:
                    return "Sql Server Is Not Running ...";
                case 2:
                    return "Sql Server Is Not Running ...";
                case 515:
                    string ReturnMe = "You Must Fill" + Environment.NewLine;
                    int tempint = 0;
                    foreach (char Chr in ex.Message.ToCharArray())
                    {
                        //Get column name from error msg and its between ''
                        char Dot = '\'';

                        if (Chr == Dot)
                            tempint++;
                        if (tempint == 1)
                            ReturnMe += Chr;
                        else if (tempint == 2)
                            break;
                    }
                    return ReturnMe + "'";
                default:
                    return ex.Message;
            }
        }
Esempio n. 10
0
        private string GetSource(Exception e)
        {
            string source = "";

            if (e.Data["PageSource"] != null)
            {
                source = e.Data["PageSource"].ToString();
            }
            else
            {
                if (e.GetType() == typeof(HttpUnhandledException))
                {
                    source = ParseStack(e.InnerException.StackTrace);
                }
                else if (e.GetType() == typeof(System.Data.SqlClient.SqlException))
                {
                    System.Data.SqlClient.SqlException sEx = (System.Data.SqlClient.SqlException)e;
                    source = sEx.Procedure;
                }
                else
                {
                    source = ParseStack(e.StackTrace);
                }
            }
            return(source);
        }
Esempio n. 11
0
        public static string CheckExp(SqlException ex)
        {
            switch (ex.Number)
            {
                case 2627:
                    return "موجود مسبقا";
                case 515:
                    string ReturnMe = "يجب مليء " + Environment.NewLine;
                    int tempint = 0;
                    foreach (char Chr in ex.Message.ToCharArray())
                    {
                        //Get column name from error msg and its between ''
                        char Dot = '\'';

                        if (Chr == Dot)
                            tempint++;
                        if (tempint == 1)
                            ReturnMe += Chr;
                        else if (tempint == 2)
                            break;
                    }
                    return ReturnMe + "'";
                case 241:
                    return String.Format("خطاء في نوع البيان {0}من فضلك فحص الارقام و التواريخ", Environment.NewLine);
                case 242:
                    return String.Format("خطاء في ادخال التاريخ {0}من فضلك تأكد ان صياغة التاريخ هي {0}سنه/شهر/يوم", Environment.NewLine);
                default:
                    return ex.Message;
            }
        }
Esempio n. 12
0
        public static string mostrarError(string strDescripcion, System.Exception objError, bool bReintentar)
        {
            int    iError     = 0;
            string strMensaje = strDescripcion + "\n\n";

            switch (objError.GetType().ToString())
            {
            case "System.Data.SqlClient.SqlException":
                System.Data.SqlClient.SqlException nuevoError = (System.Data.SqlClient.SqlException)objError;
                iError = nuevoError.Number;
                switch (nuevoError.Number)
                {
                case 17:
                    strMensaje += "El servidor SQL no existe o se ha denegado el acceso.";
                    break;

                case 547:
                    //strMensaje += "Conflicto de integridad referencial \npor parte del objeto "+ nuevoError.Procedure;
                    strMensaje += "Denegado. El sistema ha detectado un problema de integridad referencial en alguno de los elementos relacionados con el registro seleccionado.";
                    break;

                case 2627:
                case 2601:
                    //strMensaje += "Conflicto de registro duplicado \npor parte del objeto "+ nuevoError.Procedure;
                    //2601: Conflicto de indice con unique.
                    strMensaje += "Denegado. El sistema ha detectado que intenta insertar un elemento duplicado.";
                    break;

                case 1505:
                    strMensaje += "Denegado. El sistema ha detectado un problema con un elemento duplicado y un índice único.";
                    break;

                case 1205:         /* Deadlock Victim */
                    bReintentar = false;
                    strMensaje += "Se ha producido un acceso concurrente a un mismo recurso, por lo que el sistema le ha excluido del proceso. Por favor, inténtelo de nuevo. Si el problema persiste, comuníquelo al CAU. Disculpe las molestias.";
                    break;

                default:
                    strMensaje += "Error: " + nuevoError.Message;
                    break;
                }
                break;

            default:
                strMensaje += "Error: " + objError.Message;
                break;
            }
            if (bReintentar)
            {
                strMensaje += "\n\nVuelva a intentarlo y, si persiste el problema, notifique la incidencia al CAU.\n\nDisculpe las molestias.";
            }
            strMensaje  = strMensaje.Replace("\n", @"\n");
            strMensaje  = strMensaje.Replace("\r", @"\n");
            strMensaje += "@#@" + iError.ToString();

            EnviarErrorEDA(strDescripcion, objError);

            return(strMensaje);
        }
 private DbException HandleForeignKey(string message, SqlException exception)
 {
     var result = new DbException(message, exception)
     {
         IsForeignKeyViolation = true
     };
     return result;
 }
Esempio n. 14
0
 private SqlExecutionException(SerializationInfo info, StreamingContext context)
    :base(info, context) {
    _server = info.GetString("_server");
    _database = info.GetString("_database");
    _sqlFile = info.GetString("_sqlFile");
    _commands = info.GetString("_commands");
    _sqlException = (SqlException)info.GetValue("_sqlException", typeof(SqlException));
 }
        static void ThrowQueueNotFoundException(Address destination, SqlException ex)
        {
            var msg = destination == null
                ? "Failed to send message. Target address is null."
                : string.Format("Failed to send message to address: [{0}]", destination);

            throw new QueueNotFoundException(destination, msg, ex);
        }
Esempio n. 16
0
 public static void LogSqlException(SqlException ex, ILog log)
 {
     log.ErrorFormat("Server: {0}, Procedure:{1} Number:{2} Message:{3}", ex.Server, ex.Procedure, ex.Number, ex.Message);
     foreach (SqlError item in ex.Errors)
     {
         log.ErrorFormat("State: {0}, Procedure: {1}, Number: {2}, LineNumber: {3}, Message:{4}", item.State, item.Procedure, item.Number, item.LineNumber, item.Message);
     }
 }
 public SqlExecutionException(string message, string server, string database, string sqlFile, string commands, SqlException sqlException) : base(message)
 {
     this._server = server;
     this._database = database;
     this._sqlFile = sqlFile;
     this._commands = commands;
     this._sqlException = sqlException;
 }
Esempio n. 18
0
        /// <summary>
        ///     Converts the specified sqle.
        /// </summary>
        /// <param name="sqle">The sqle.</param>
        /// <param name="exInfo">The ex info.</param>
        /// <returns>Exception thrown by NHibernate</returns>
        private System.Exception Convert(SqlException sqle, AdoExceptionContextInfo exInfo)
        {
            System.Exception finalException;
            if (sqle != null)
            {
                switch (sqle.Number)
                {
                    case 17:
                    // SQL Server does not exist or access denied. 
                    case 4060:
                    // Invalid Database 
                    case 18456:
                        // Login Failed 
                        finalException = new DbLoginException(sqle.Message, sqle);
                        break;

                    case 1205:
                        // DeadLock Victim 
                        finalException =
                            new DbDeadLockException(sqle.Message, sqle);
                        break;

                    case 2627:
                    case 2601:
                        // Unique Index/Constriant Violation 
                        finalException =
                            new DbUniqueConstraintException(sqle.Message, sqle);
                        break;
                    case 547:
                        finalException =
                            new DbForeignKeyException(sqle.Message, sqle);
                        break;

                    case 208:
                        finalException =
                            new SQLGrammarException(
                                exInfo.Message, sqle.InnerException, exInfo.Sql);
                        break;

                    case 3960: // in case of snapshot isolation
                        finalException =
                            new StaleObjectStateException(exInfo.EntityName, exInfo.EntityId);
                        break;

                    default:
                        finalException =
                            SQLStateConverter.HandledNonSpecificException(exInfo.SqlException, exInfo.Message,
                                exInfo.Sql);
                        break;
                }
            }
            else
            {
                finalException = SQLStateConverter.HandledNonSpecificException(exInfo.SqlException, exInfo.Message,
                    exInfo.Sql);
            }
            return finalException;
        }
Esempio n. 19
0
 public static bool checkUniqueViolationException(String mensaje, SqlException Ex)
 {
     if (Ex.Number == 2627)
     {
         MessageBox.Show(mensaje, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
         return true;
     }
     return false;
 }
 public static bool ReexecuteCommand(SqlException sqlException, ref SqlCommand command) {
     if (SqlExceptionsThatCauseRederivingSqlCommand.Values.Contains(sqlException.Number)) {
         command = CommandMethods.RederiveCommand(command);
         if (command != null) {
             return true;
         }
     }
     return false;
 }
Esempio n. 21
0
        public static string mostrarErrorAjax(string strDescripcion, System.Exception objError)
        {
            int    iError     = 0;
            string strMensaje = strDescripcion + (char)10 + (char)10;

            switch (objError.GetType().ToString())
            {
            case "System.Data.SqlClient.SqlException":
                System.Data.SqlClient.SqlException nuevoError = (System.Data.SqlClient.SqlException)objError;
                iError = nuevoError.Number;
                switch (nuevoError.Number)
                {
                case 17:
                    strMensaje += "El servidor SQL no existe o se ha denegado el acceso.";
                    break;

                case 547:
                    //strMensaje += "Conflicto de integridad referencial \npor parte del objeto "+ nuevoError.Procedure;
                    strMensaje += "Denegado. El sistema ha detectado un problema de integridad referencial en alguno de los elementos relacionados con el registro seleccionado.";
                    break;

                case 2627:
                case 2601:
                    //strMensaje += "Conflicto de registro duplicado \npor parte del objeto "+ nuevoError.Procedure;
                    //2601: Conflicto de indice con unique.
                    strMensaje += "Denegado. El sistema ha detectado que intenta insertar un elemento duplicado.";
                    break;

                case 1505:
                    strMensaje += "Denegado. El sistema ha detectado un problema con un elemento duplicado y un índice único.";
                    break;

                case 1205:         /* Deadlock Victim */
                    strMensaje += "Se ha producido un acceso concurrente a un mismo recurso, por lo que el sistema le ha excluido del proceso.";
                    break;

                case -2:
                    strMensaje += "Se ha producido un acceso concurrente a un mismo recurso, por lo que el sistema ha dado un error de tiempo de espera.";
                    break;

                default:
                    strMensaje += "Error: " + nuevoError.Message;
                    break;
                }
                break;

            default:
                strMensaje += "Error: " + objError.Message;
                break;
            }
            strMensaje  = strMensaje + (char)10 + (char)10 + "Vuelve a intentarlo y, si persiste el problema, notifica la incidencia al CAU." + (char)10 + (char)10 + "Disculpa las molestias.";
            strMensaje += "@#@" + iError.ToString();

            //EnviarErrorEDA(strDescripcion, objError);

            return(strMensaje);
        }
Esempio n. 22
0
        /// <summary>
        /// Transforms the specified SQL Server exception into the appropriate Nexon.Framework
        /// exception.
        /// </summary>
        /// <param name="exception">SQL Exception instance</param>
        /// <returns>
        /// Transformed Nexon.Framework exception.
        /// </returns>
        public static Exception TransformSqlException(SqlException exception)
        {
            // --- Check for primary key violation
            const string PK_ERROR_PATTERN = @"primary key constraint '(.+?)'.*in object '(.+?)'";
            var regex = new Regex(PK_ERROR_PATTERN, RegexOptions.IgnoreCase);
            var match = regex.Match(exception.Message);
            if (match.Success)
            {
                return new PrimaryKeyViolationException(match.Groups[2].Captures[0].Value, exception);
            }

            // --- Check for unique key violation
            const string UK_ERROR_PATTERN1 = @"unique key constraint '(.+?)'.*in object '(.+?)'";
            regex = new Regex(UK_ERROR_PATTERN1, RegexOptions.IgnoreCase);
            match = regex.Match(exception.Message);
            if (match.Success)
            {
                return new UniqueKeyViolationException(match.Groups[2].Captures[0].Value,
                                                      match.Groups[1].Captures[0].Value, exception);
            }

            const string UK_ERROR_PATTERN2 = @"Cannot insert duplicate key row in object '(.+?)' with unique index '(.+?)'.";
            regex = new Regex(UK_ERROR_PATTERN2, RegexOptions.IgnoreCase);
            match = regex.Match(exception.Message);
            if (match.Success)
            {
                return new UniqueKeyViolationException(match.Groups[1].Captures[0].Value,
                                                      match.Groups[2].Captures[0].Value, exception);
            }

            // --- Check for foreign key violation
            const string FK1_ERROR_PATTERN = "foreign key constraint \"(.+?)\"";
            regex = new Regex(FK1_ERROR_PATTERN, RegexOptions.IgnoreCase);
            match = regex.Match(exception.Message);
            if (match.Success)
            {
                return new ForeignKeyViolationException(match.Groups[1].Captures[0].Value, exception);
            }
            const string FK2_ERROR_PATTERN = "reference constraint \"(.+?)\"";
            regex = new Regex(FK2_ERROR_PATTERN, RegexOptions.IgnoreCase);
            match = regex.Match(exception.Message);
            if (match.Success)
            {
                return new ForeignKeyViolationException(match.Groups[1].Captures[0].Value, exception);
            }

            // --- Check for NULL insertion
            const string NULL_ERROR_PATTERN = @"Cannot insert the value NULL into column '(.+?)'.*table '(.+?)'";
            regex = new Regex(NULL_ERROR_PATTERN, RegexOptions.IgnoreCase);
            match = regex.Match(exception.Message);
            if (match.Success)
            {
                return new NullValueNotAllowedException(match.Groups[2].Captures[0].Value,
                                                      match.Groups[1].Captures[0].Value, exception);
            }
            return exception;
        }
Esempio n. 23
0
 public object Result(int i)
 {
     if (_ds == null)
     {
         System.Data.SqlClient.SqlException se = _Err as System.Data.SqlClient.SqlException;
         return(JsonConvert.DeserializeObject(JsonConvert.SerializeObject(se.Errors)));
     }
     return(JsonConvert.DeserializeObject(JsonConvert.SerializeObject(_ds.Tables[i], Formatting.None)));
 }
    public static string SqlException_Message(SqlException ex)
    {
        string STSsqlException = "";
            switch (ex.Number)
            {
                case 17:
                    {
                        STSsqlException = "Database Error";
                        break;
                    }
                case -2:
                    {
                        STSsqlException = "Connection timeout";
                        break;
                    }
                case 18456:
                case 1326:
                    {
                        STSsqlException = "Login Failed";
                        break;
                    }
                case 4060:
                    {
                        STSsqlException = "Database not found";
                        break;
                    }
                case 229:
                    {
                        STSsqlException = "Login Credentials Failed";
                        break;
                    }

                case 2601:
                case 2627:
                    {
                        STSsqlException = "Unique Key Voilation";
                        break;
                    }
                case 547:
                    {
                        STSsqlException = "General Error - Foreign Key Voilation";
                        break;
                    }
                case 8152:
                    {
                        STSsqlException = "General Error - DATA TRUNCATION";
                        break;
                    }
                default:
                    {
                        STSsqlException = ex.Message.ToString();
                        break;
                    }
            }
            return STSsqlException;
    }
        public static SqlException[] GenerateFakeSqlExceptions(params int[] errorCodes)
        {
            SqlException[] exceptions = new SqlException[errorCodes.Length];

            for (int i = 0; i < errorCodes.Length; i++)
            {
                exceptions[i] = GenerateFakeSqlException(errorCodes[i]);
            }

            return exceptions;
        }
Esempio n. 26
0
 public void tratarSqlExceções(SqlException sqlex)
 {
     int erro = sqlex.ErrorCode;
     if (erro == -2146232060)
     {
         MessageBox.Show("Campo(s) Obrigatório(s) não preenchido(s).", "Erro", MessageBoxButtons.OK, MessageBoxIcon.Error);
     }
     else
     {
         MessageBox.Show("Erro desconhecido.\nContate o administrador do sistema", "Erro", MessageBoxButtons.OK, MessageBoxIcon.Error);
     }
 }
Esempio n. 27
0
File: DB.cs Progetto: D8CNPM/ASP.NET
 public static void ExceptionInfo(SqlException exc,ref Alert al)
 {
     switch (exc.Number)
     {
         case ERR_KEYCONFLICT:
             al = new Alert("danger", "Lỗi dữ liệu", "Khóa chính bị trùng!");
             break;
         default:
             al = new Alert("warning", "Lỗi SQL " + exc.Number, exc.Message);
             break;
     }
 }
Esempio n. 28
0
 private Exception TranslateSqlServerErrors(SqlException ex)
 {
     if (ex.Errors.OfType<SqlError>().Any(e => e.Number == 2601))
     {
         return new UniqueConstraintViolationException(ex.Errors.OfType<SqlError>().Where(e => e.Number == 2601).Select(e => ConstructUniqueConstraintDetail(e.Message)).ToList());
     }
     else if (ex.Errors.OfType<SqlError>().Any(e => e.Number == 547))
     {
         return new FKViolationException(ex.Errors.OfType<SqlError>().Where(e => e.Number == 547).Select(e => ConstructFKDetail(e.Message)).ToList());
     }
     return ex;
 }
Esempio n. 29
0
        public static void SqlExceptionHandling(SqlException sqlex, string strModule, string strMethod, string strMsg)
        {
            EventLog objEventLog = new EventLog();

            string strApplicationName = "SLDDBLog";
            objEventLog.Source = strApplicationName;

            objEventLog.Log = strApplicationName;
            objEventLog.WriteEntry(Environment.NewLine + "Date : " + DateTime.Now + Environment.NewLine + "Module Name : " + strModule + Environment.NewLine + "Method Name : " + strMethod + Environment.NewLine + "Exception Number : " + sqlex.ErrorCode + Environment.NewLine + "Exception Message : " + sqlex.Message + Environment.NewLine + "Additional Information : " + strMsg, EventLogEntryType.Error);
            objEventLog.Close();
            objEventLog.Dispose();
        }
        public static bool IsTransient(SqlException sqlEx)
        {
            if (sqlEx.Number == 1205 // 1205 = Deadlock
                || sqlEx.Number == -2 // -2 = TimeOut
                || sqlEx.Number == -1 // -1 = Connection
                || sqlEx.Number == 2 // 2 = Connection
                || sqlEx.Number == 53 // 53 = Connection
                )
                return true;

            return false;
        }
Esempio n. 31
0
        public ValidationExceptionParser(string tableName, SqlException ex)
        {
            foreach (SqlError e in ex.Errors)
            {
                switch (e.Number)
                {
                    case 2627: ValidationErrorMessage += string.Format(" {0}: data must be unique in table {1}", e.Number, tableName); break;
                    case 3621:
                        continue;
                }

            }
        }
Esempio n. 32
0
 public static void ThrowException(string title, SqlException e)
 {
     for (int i = 0; i < e.Errors.Count; i++)
     {
         MessageBox.Show("Error #" + i +
                         "\nMessage: " + e.Errors[i].Message +
                         ((e.Errors[i].Source == string.Empty) ? string.Empty : "\nSource: " + e.Errors[i].Source) +
                         ((e.Errors[i].Procedure == string.Empty)
                             ? string.Empty
                             : "\nProceedure: " + e.Errors[i].Procedure),
             title, MessageBoxButtons.OK, MessageBoxIcon.Error);
     }
 }
 public static void AddDetailsToException(this SqlCommand command, SqlException e)
 {
     var procedureName = String.Format("Procedure Name: {0}", command.CommandText);
     e.Data[Global.ProcNameExceptionDataKey] = procedureName;
     var parameters = String.Format("Passed parameters: {0}", Environment.NewLine);
     foreach (SqlParameter sqlParam in command.Parameters)
     {
         var paramValue = sqlParam.Value != null ? sqlParam.Value.ToString() : "";
         parameters = parameters + sqlParam.ParameterName + ": " + paramValue +
             "(" + sqlParam.Size.ToString() + "), ";
     }
     e.Data[Global.ParamExceptionDataKey] = parameters.Remove(parameters.Length - 2);
 }
Esempio n. 34
0
 public static void Handle(SqlException exception)
 {
     var message = exception.Message.ToUpperInvariant();
     foreach (var key in ConstraintMessages.Keys)
     {
         if (message.Contains(key))
         {
             MessageBox.Show(ConstraintMessages[key]);
             return;
         }
     }
     MessageBox.Show(exception.Message);
 }
 internal SqlException InternalClone()
 {
     SqlException exception = new SqlException(this.Message, this._errors);
     if (this.Data != null)
     {
         foreach (DictionaryEntry entry in this.Data)
         {
             exception.Data.Add(entry.Key, entry.Value);
         }
     }
     exception._doNotReconnect = this._doNotReconnect;
     return exception;
 }
        /// <summary>
        /// Logs information specific to SQL Exceptions
        /// </summary>
        /// <param name="log"></param>
        /// <param name="ex"></param>
        public static void LogSqlException(this ILog log, SqlException ex)
        { 
            log.ErrorFormat("Server: {0}, Procedure:{1} Number:{2} Message:{3}", ex.Server, ex.Procedure, ex.Number, ex.Message);
            foreach (SqlError item in ex.Errors)
            {
                log.ErrorFormat("State: {0}, Procedure: {1}, Number: {2}, LineNumber: {3}, Message:{4}", item.State, item.Procedure, item.Number, item.LineNumber, item.Message);
            }

            if (ex.Number == ForeignKeyConstraintViolation)
            {
                log.Error("Foreign Key Constraint Violation!");
            }
        }
 // Constraint and duplicate key exception
 // Refer to: http://msdn.microsoft.com/en-us/library/cc645603.aspx
 /// <summary>
 /// Creates new instance of DataConstraintException class
 /// </summary>
 /// <param name="ex"></param>
 public DataConstraintException(SqlException ex)
     : base(ex.Message, ex)
 {
     if (ex.Number == 547)
     {
         this.ParseTableName(ex.Message);
         this.Kind = DataConstraindErrorKind.Constraint;
     }
     else if (ex.Number == 2627 || ex.Number == 2601)
     {
         this.Kind = DataConstraindErrorKind.DuplicateKey;
     }
 }
Esempio n. 38
0
        private static bool CheckErrorCanRetry(System.Data.SqlClient.SqlException e)
        {
            bool   CanRetry = false;
            string TempMsg  = e.ToString().ToLower();

            if (e.Number == 11) //general network error
            {
                CanRetry = true;
            }
            else if (e.Number == 17) //sql server does not exist or access denied
            {
                CanRetry = true;
            }
            else if (e.Number == -2) //timeout expired
            {
                CanRetry = true;
            }
            else if (e.Number == 1205) //deadlocked on lock
            {
                CanRetry = true;
            }
            else if (TempMsg.IndexOf("逾時") > 0)
            {
                CanRetry = true;
            }
            else if (TempMsg.IndexOf("timeout expired") > 0)
            {
                CanRetry = true;
            }
            else if (TempMsg.IndexOf("一般性網路") > 0)
            {
                CanRetry = true;
            }
            else if (TempMsg.IndexOf("一般網路") > 0)
            {
                CanRetry = true;
            }
            else if (TempMsg.IndexOf("general network error") > 0)
            {
                CanRetry = true;
            }
            else if (TempMsg.IndexOf("不存在或拒絕存取") > 0)
            {
                CanRetry = true;
            }
            else if (TempMsg.IndexOf("sql server does not exist") > 0)
            {
                CanRetry = true;
            }
            return(CanRetry);
        }
Esempio n. 39
0
        public static bool IsExceptionAForeignKeyViolation(System.Data.SqlClient.SqlException ex)
        {
            bool isForeignKeyViolation = false;

            foreach (System.Data.SqlClient.SqlError error in ex.Errors)
            {
                if (error.Number == 547)
                {
                    isForeignKeyViolation = true;
                }
            }

            return(isForeignKeyViolation);
        }
Esempio n. 40
0
 protected void grdCustomerFollowupAction_RowDeleted(object sender, GridViewDeletedEventArgs e)
 {
     if (e.Exception != null)
     {
         if (e.Exception.InnerException is System.Data.SqlClient.SqlException)
         {
             System.Data.SqlClient.SqlException err = e.Exception.InnerException as System.Data.SqlClient.SqlException;
             if (err.ErrorCode.Equals(Convert.ToInt32("0x80131904", 16)))
             {
                 ShowError(Resources.Exception.DeletingRegisterWithForeignKey);
                 e.ExceptionHandled = true;
             }
         }
     }
 }
Esempio n. 41
0
 protected void grdScheduleTasks_RowDeleted(object sender, GridViewDeletedEventArgs e)
 {
     if (e.Exception != null)
     {
         if (e.Exception.InnerException is System.Data.SqlClient.SqlException)
         {
             System.Data.SqlClient.SqlException err = e.Exception.InnerException as System.Data.SqlClient.SqlException;
             if (err.ErrorCode.Equals(Convert.ToInt32("0x80131904", 16)))
             {
                 ShowError("O registro não pode ser apagado pois há outros registros associados!");
                 e.ExceptionHandled = true;
             }
         }
     }
 }
Esempio n. 42
0
 protected void odsServices_Deleted(object sender, ObjectDataSourceStatusEventArgs e)
 {
     if (e.Exception != null)
     {
         if (e.Exception.InnerException is System.Data.SqlClient.SqlException)
         {
             System.Data.SqlClient.SqlException err = e.Exception.InnerException as System.Data.SqlClient.SqlException;
             if (err.ErrorCode.Equals(Convert.ToInt32("0x80131904", 16)))
             {
                 ShowError(Resources.Exception.DeletingRegisterWithForeignKey);
                 e.ExceptionHandled = true;
             }
         }
     }
 }
        public String RegistrarExcepcion(Exception excepcion, String origen)
        {
            string mensaje = "";

            try
            {
                if (excepcion is System.ApplicationException)
                {
                    System.ApplicationException exc = (System.ApplicationException)excepcion;
                    mensaje = EscribirApplicationException(exc, origen);
                }
                else if (excepcion is System.IO.InvalidDataException)
                {
                    System.IO.InvalidDataException exc = (System.IO.InvalidDataException)excepcion;
                    mensaje = EscribirInvalidDataException(exc, origen);
                }
                else if (excepcion is System.IO.IOException)
                {
                    System.IO.IOException exc = (System.IO.IOException)excepcion;
                    mensaje = EscribirIOEx(exc, origen);
                }
                else if (excepcion is System.FormatException)
                {
                    System.FormatException exc = excepcion as System.FormatException;
                    mensaje = EscribirFormatException(exc, origen);
                }
                else if (excepcion is System.Data.SqlClient.SqlException)
                {
                    System.Data.SqlClient.SqlException exc = excepcion as System.Data.SqlClient.SqlException;
                    mensaje = EscribirSqlEx(exc, origen);
                }
                else if (excepcion is System.Data.OleDb.OleDbException)
                {
                    System.Data.OleDb.OleDbException exc = excepcion as System.Data.OleDb.OleDbException;
                    mensaje = EscribirOleDbEx(exc, origen);
                }
                else
                {
                    mensaje = EscribirGenericEx(excepcion, origen);
                }
            }
            catch (Exception ex)
            {
                mensaje = "Error interno de la Aplicación. Por favor informar a Sopórte Técnico.\n\n";
                mensaje = mensaje + EscribirLocalEx(ex, this.ToString() + ".RegistrarExcepcion");
            }
            return(mensaje);
        }
Esempio n. 44
0
 protected void odsRoles_Deleted(object sender, ObjectDataSourceStatusEventArgs e)
 {
     if (e.Exception != null)
     {
         if (e.Exception.InnerException is System.Data.SqlClient.SqlException)
         {
             System.Data.SqlClient.SqlException err = e.Exception.InnerException as System.Data.SqlClient.SqlException;
             if (err.ErrorCode.Equals(Convert.ToInt32("0x80131904", 16)))
             {
                 lblErr.Visible     = true;
                 lblErr.Text        = "O registro não pode ser apagado pois há outros registros associados!";
                 e.ExceptionHandled = true;
             }
         }
     }
 }
Esempio n. 45
0
    protected void Page_Load(object sender, EventArgs e)
    {
        Util.setCSS();
        labApplicationName.Text = Util.getAppSetting("app://ApplicationName/");
        if (Server.GetLastError() != null)
        {
            string strErrType = "";
            string strErrMsg  = "";

            //SqlException
            if (string.IsNullOrEmpty(strErrType))
            {
                if (Server.GetLastError().GetBaseException() is System.Data.SqlClient.SqlException)
                {
                    //SqlException
                    System.Data.SqlClient.SqlException ex = (System.Data.SqlClient.SqlException)Server.GetLastError().GetBaseException();
                    strErrType += string.Format(SinoPac.WebExpress.Common.Properties.Resources.Msg_ErrorType, ex.GetType().Name);
                    strErrType += " " + string.Format(SinoPac.WebExpress.Common.Properties.Resources.Msg_ErrorCode, ex.ErrorCode);
                    strErrMsg  += ex.Message.ToString();
                }
            }

            //HttpException
            if (string.IsNullOrEmpty(strErrType))
            {
                if (Server.GetLastError().GetBaseException() is HttpException)
                {
                    HttpException ex = (HttpException)Server.GetLastError().GetBaseException();
                    strErrType += string.Format(SinoPac.WebExpress.Common.Properties.Resources.Msg_ErrorType, ex.GetType().Name);
                    strErrType += " " + string.Format(SinoPac.WebExpress.Common.Properties.Resources.Msg_ErrorCode, ex.GetHttpCode());
                    strErrMsg  += ex.Message.ToString();
                }
            }

            //Exception
            if (string.IsNullOrEmpty(strErrType))
            {
                Exception ex = (Exception)Server.GetLastError().GetBaseException();
                strErrType += string.Format(SinoPac.WebExpress.Common.Properties.Resources.Msg_ErrorType, ex.GetType().Name);
                strErrMsg  += ex.Message.ToString();
            }

            labErrType.Text = Util.getHtmlMessage(Util.HtmlMessageKind.Error, strErrType);
            labErrMsg.Text  = string.Format("<div class='Util_Frame' style='padding:10px;background-color: #ccc;'>{0}</div>", strErrMsg);
        }
    }
Esempio n. 46
0
        public string SaveChanges()
        {
            string message = "aqui no hay nada XD";

            try
            {
                var usuarioDataModel = new usuario();
                usuarioDataModel.id_user     = id_user;
                usuarioDataModel.username    = username;
                usuarioDataModel.pass        = pass;
                usuarioDataModel.empleado_id = empleado_id;
                usuarioDataModel.estado      = estado;

                switch (State)
                {
                case EntityState.Added:
                    usuarioRepository.Add(usuarioDataModel);
                    message = "Ha sido Registrado";
                    break;

                case EntityState.Modified:
                    usuarioRepository.Adit(usuarioDataModel);
                    message = "Ha sido Modificado";
                    break;

                case EntityState.Deleted:
                    usuarioRepository.Remove(id_user);
                    message = "El usuario ha sido invalidado";
                    break;
                }
            }
            catch (Exception ex)
            {
                System.Data.SqlClient.SqlException sqlEx = ex as System.Data.SqlClient.SqlException;
                if (sqlEx != null && sqlEx.Number == 2627)
                {
                    message = "El usuario ya existe";
                }
                else
                {
                    message = ex.ToString();
                }
            }

            return(message);
        }
        public static Object ExecuteScalarCmd(SqlCommand sqlCmd)
        {
            if (sqlCmd == null)
            {
                throw (new ArgumentNullException("sqlCmd"));
            }

            Object        result = null;
            SqlConnection cn     = new SqlConnection(Utilidades.CadenaConexion);

            sqlCmd.Connection     = cn;
            sqlCmd.CommandTimeout = 60;
            cn.Open();
            //sqlCmd.ExecuteScalar();

            try
            {
                result = sqlCmd.ExecuteScalar();
            }
            catch (System.Exception objError)
            {
                switch (objError.GetType().ToString())
                {
                case "System.Data.SqlClient.SqlException":
                    System.Data.SqlClient.SqlException nuevoError = (System.Data.SqlClient.SqlException)objError;
                    switch (nuevoError.Number)
                    {
                    case 547:
                        result = "Denegado. El sistema ha detectado elementos relacionados con el registro seleccionado. ";
                        break;

                    default:
                        result = "Error de Sql Server: " + nuevoError.Message;
                        break;
                    }
                    break;

                default:
                    result += "Error: " + objError.Message;
                    break;
                }
            }

            return(result);
        }
Esempio n. 48
0
 protected void odsDinamicReports_Deleted(object sender, ObjectDataSourceStatusEventArgs e)
 {
     //
     // This method is to not allow deleting items that are associated with others Tables
     //
     if (e.Exception != null)
     {
         if (e.Exception.InnerException is System.Data.SqlClient.SqlException)
         {
             System.Data.SqlClient.SqlException err = e.Exception.InnerException as System.Data.SqlClient.SqlException;
             if (err.ErrorCode.Equals(Convert.ToInt32("0x80131904", 16)))
             {
                 //ShowError(Resources.Exception.DeletingRegisterWithForeignKey);
                 e.ExceptionHandled = true;
             }
         }
     }
 }
Esempio n. 49
0
        public static string mostrarError(string strDescripcion, System.Exception objError, bool bReintentar)
        {
            string strMensaje = strDescripcion + "\n\n";

            switch (objError.GetType().ToString())
            {
            case "System.Data.SqlClient.SqlException":
                System.Data.SqlClient.SqlException nuevoError = (System.Data.SqlClient.SqlException)objError;
                switch (nuevoError.Number)
                {
                case 17:
                    strMensaje += "El servidor SQL no existe o se ha denegado el acceso.";
                    break;

                case 547:
                    //strMensaje += "Conflicto de integridad referencial \npor parte del objeto "+ nuevoError.Procedure;
                    strMensaje += "Denegado. El sistema ha detectado un problema de integridad referencial en alguno de los elementos relacionados con el registro seleccionado.";
                    break;

                case 2627:
                case 2601:
                    //strMensaje += "Conflicto de registro duplicado \npor parte del objeto "+ nuevoError.Procedure;
                    //2601: Conflicto de indice con unique.
                    strMensaje += "Denegado. El sistema ha detectado que intenta insertar un elemento duplicado.@@" + nuevoError.Number.ToString();
                    break;

                default:
                    strMensaje += "Error: " + nuevoError.Message;
                    break;
                }
                break;

            default:
                strMensaje += "Error: " + objError.Message;
                break;
            }
            if (bReintentar)
            {
                strMensaje += "\n\nVuelva a intentarlo y, si persiste el problema, notifique la incidencia al CAU.\n\nDisculpe las molestias.";
            }
            strMensaje = strMensaje.Replace("\n", @"\n");
            strMensaje = strMensaje.Replace("\r", @"\n");
            return(strMensaje);
        }
Esempio n. 50
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="pException"></param>
        /// <param name="pCnnString"></param>
        public DataBaseExeption(Exception pException, CnnString pCnnString)
        {
            _CnnString = pCnnString;


            if (pException.GetType() == typeof(System.Security.Cryptography.CryptographicException))
            {
                _Msg = "La password encriptada en el archivo de configuracion fue violada. "
                       + Environment.NewLine + "Reescriba su clave y guarde su configuracion";
            }
            if (pException.GetType() == typeof(SqlException))
            {
                System.Data.SqlClient.SqlException ex = (System.Data.SqlClient.SqlException)pException;
                //ex.Number == 18456 Login fail
                _Msg = pException.Message + Environment.NewLine + "Vuelva a ingresar la informacion de conección";
            }
            if (pException.GetType() == typeof(System.IO.FileNotFoundException))
            {
                _Msg = pException.Message;
            }
        }
Esempio n. 51
0
        public static string mostrarError(string strDescripcion, System.Exception objError)
        {
            string strMensaje = strDescripcion + "\n\n";

            switch (objError.GetType().ToString())
            {
            case "System.Data.SqlClient.SqlException":
                System.Data.SqlClient.SqlException nuevoError = (System.Data.SqlClient.SqlException)objError;
                switch (nuevoError.Number)
                {
                case 17:
                    strMensaje += "El servidor SQL no existe o se ha denegado el acceso.";
                    break;

                case 547:
                    //strMensaje += "Conflicto de integridad referencial \npor parte del objeto "+ nuevoError.Procedure;
                    strMensaje += "Denegado. El sistema ha detectado elementos relacionados con el registro seleccionado.";
                    break;

                case 2627:
                    //strMensaje += "Conflicto de registro duplicado \npor parte del objeto "+ nuevoError.Procedure;
                    strMensaje += "Denegado. El sistema ha detectado que intenta insertar un elemento duplicado.";
                    break;

                default:
                    strMensaje += "Error: " + nuevoError.Message;
                    break;
                }
                break;

            default:
                strMensaje += "Error: " + objError.Message;
                break;
            }
            strMensaje = strMensaje.Replace("\n", @"\n");
            strMensaje = strMensaje.Replace("\r", @"\n");

            return(strMensaje);
        }
Esempio n. 52
0
    //protected void grdCompanies_Sorting(object sender, GridViewSortEventArgs e)
    //{
    //    if (e.SortExpression == "Insert")
    //    {
    //        Server.Transfer("Company.aspx");
    //    }
    //}

    //protected void grdCompanies_SelectedIndexChanging(object sender, GridViewSelectEventArgs e)
    //{
    //    Context.Items["CompanyId"] = grdCompanies.DataKeys[e.NewSelectedIndex]["CompanyId"].ToString();
    //    Server.Transfer("Company.aspx");
    //}

    protected void odsCompanies_Deleted(object sender, ObjectDataSourceStatusEventArgs e)
    {
        //
        // This method is to not allow deleting Products that are associated with others Tables
        //
        if (e.Exception != null)
        {
            if (e.Exception.InnerException is System.Data.SqlClient.SqlException)
            {
                System.Data.SqlClient.SqlException err = e.Exception.InnerException as System.Data.SqlClient.SqlException;
                if (err.ErrorCode.Equals(Convert.ToInt32("0x80131904", 16)))
                {
                    ShowError(Resources.Exception.DeletingRegisterWithForeignKey);
                    e.ExceptionHandled = true;
                }
            }
        }
        else
        {
            Page.ClientScript.RegisterStartupScript(this.GetType(), "", "top.ResetHeader();", true);
        }
    }
Esempio n. 53
0
        public static SQLErrorEnums HandleFormValidations(DbUpdateException ex)
        {
            SQLErrorEnums sqlerr = SQLErrorEnums.Username;

            if (ex.InnerException != null)
            {
                UpdateException ue = (UpdateException)ex.InnerException;
                if (ue.InnerException != null)
                {
                    System.Data.SqlClient.SqlException sqlex = (System.Data.SqlClient.SqlException)ue.InnerException;
                    ErrorCode = sqlex.Number.ToString();
                    if (sqlex.Message.Contains("Username"))
                    {
                        sqlerr = SQLErrorEnums.Username;
                    }
                    else if (sqlex.Message.Contains("ClientName"))
                    {
                        sqlerr = SQLErrorEnums.ClientName_AlreadyExists;
                    }
                }
            }

            return(sqlerr);
        }
Esempio n. 54
0
 internal void OnError(SqlException exception, bool breakConnection, Action <Action> wrapCloseInAction)
 => throw new PlatformNotSupportedException(EXCEPTION_MESSAGE);
Esempio n. 55
0
        public static void Throw(Exception e)
        {
            Debug.Enter();

            //
            // If this is a UDDI exception get the error number
            // Otherwise map all other errors to E_fatalError
            //
            ErrorType et           = ErrorType.E_fatalError;
            string    debugMessage = "";

            if (e is UDDI.UDDIException)
            {
                et = (ErrorType)((UDDIException)e).Number;
            }
            else if (e is System.Data.SqlClient.SqlException)
            {
                //
                // SECURITY: SqlException's include stored procedure names
                // This information is flowing back to the client in the SOAPFault
                // information. This information should be logged and not returned.
                //
                System.Data.SqlClient.SqlException se = (System.Data.SqlClient.SqlException)e;

                //
                // Build a detailed message about the exception; this text is not sent back to the user.
                //
                debugMessage = "SQL Exception in " + se.Procedure +
                               " line " + se.LineNumber +
                               " [severity " + se.Class +
                               ", state " + se.State;

                debugMessage += ", server " + se.Server;
                debugMessage += "]";

                //
                // Is this one of our custom error messages?  If so, we'll masssage the
                // error code into one of the UDDIException error types (custom errors
                // are thrown as ErrorType + 50000).  Otherwise, we'll simply use
                // E_fatalError.
                //
                if (16 == se.Class)
                {
                    et = (ErrorType)(se.Number - 50000);
                }
                else
                {
                    //
                    // 739178 - See if this was a SQL deadlock issue.  If it was, then return an E_serverBusy error
                    // instead.  The 1205 number is a retrieved from sysmessages table in the masters database of
                    // SQL Server.  See the SQL Books Online for more information about 1205.
                    //
                    if (1205 == se.Number)
                    {
                        //
                        // Change the 'e' variable to a new exception; need to do this since e.Message
                        // is read-only.  Keep track of the original exception so we can log it.
                        //
                        Exception originalException = e;
                        e  = new UDDIException(ErrorType.E_busy, "ERROR_BUSY");
                        et = ErrorType.E_busy;

                        Debug.Write(SeverityType.Info, CategoryType.Data, "A deadlock exception has been converted to an E_busy exception.  The original exception was:\r\n" + originalException.ToString());
                    }
                    else
                    {
                        et = ErrorType.E_fatalError;
                    }
                }
            }

            //
            // Log this error message.
            //
            Debug.Write(SeverityType.Info, CategoryType.Data, "An exception occurred. Details Follow:\r\n" + e.ToString() + "\r\n\r\n" + debugMessage);

            //
            // if this is a V1.0 call, map any new V2.0 error codes to
            // v1.0 error codes
            //
            if (1 == Context.ApiVersionMajor)
            {
                switch (et)
                {
                case ErrorType.E_invalidValue:
                case ErrorType.E_valueNotAllowed:
                case ErrorType.E_invalidProjection:
                case ErrorType.E_assertionNotFound:
                case ErrorType.E_invalidCompletionStatus:
                case ErrorType.E_messageTooLarge:
                case ErrorType.E_transferAborted:
                case ErrorType.E_publisherCancelled:
                case ErrorType.E_requestDenied:
                case ErrorType.E_secretUnknown:
                    et = ErrorType.E_fatalError;
                    break;
                }
            }

            //
            // Construct a new instance of a disposition report
            //
            DispositionReport dr = new DispositionReport(et, e.Message);

            //
            // Serialize the disposition report to a stream and load into
            // a DOM.
            //
            XmlDocument doc = new XmlDocument();

            MemoryStream strm = new MemoryStream();

            // XmlSerializer serializer = new XmlSerializer( typeof( DispositionReport ) );
            XmlSerializer serializer = XmlSerializerManager.GetSerializer(typeof(DispositionReport));

            serializer.Serialize(strm, dr);
            strm.Position = 0;

            doc.Load(strm);

            //
            // Wrap the disposition report with a detail node.
            //
            XmlNode detail = doc.CreateNode(
                XmlNodeType.Element,
                SoapException.DetailElementName.Name,
                SoapException.DetailElementName.Namespace);

            detail.AppendChild(doc.FirstChild.NextSibling);

            //
            // Construct the SOAP exception using the dr XML
            // as details and the received Exception as the inner exception.
            //

            UDDIText uddiText = new UDDIText("ERROR_FATAL_ERROR");

            throw new UDDISoapException(uddiText.GetText(),
                                        SoapException.ClientFaultCode,
                                        "",
                                        detail,
                                        e);
        }