예제 #1
0
        private String FormatDbException
            (DbException dbex)
        {
            StringBuilder sb = new StringBuilder();

            sb.Append("HRESULT: ").AppendLine(dbex.ErrorCode.ToString())
            .Append("Message: ").AppendLine(dbex.Message);
            if (!String.IsNullOrEmpty(dbex.HelpLink))
            {
                sb.Append("Help Link: ").AppendLine(dbex.HelpLink);
            }

            if (!String.IsNullOrEmpty(dbex.Source))
            {
                sb.Append("Source: ").AppendLine(dbex.Source);
            }

            if (null != dbex.TargetSite)
            {
                sb.Append("Target Site:").AppendLine(dbex.TargetSite.ToString());
            }

            if (null != dbex.InnerException)
            {
                sb.AppendLine("Inner exception:").AppendLine(dbex.ToString());
            }
            sb.AppendLine("StackTrace:").AppendLine(dbex.StackTrace);
            return(sb.ToString());
        }
예제 #2
0
 protected static void TreatDbException(DbException sqlx)
 {
     if (IsBusinessRuleException(sqlx))
     {
         //Implementation of BusinessRulesException
         throw new Exception(ExtractErrorCode(sqlx), sqlx);
     }
     throw new Exception(sqlx.ToString(), sqlx);
 }
예제 #3
0
 public static void HandleDbException(DbException exception)
 {
     if (exception is MySqlException mySqlException)
     {
         Logger.GetInstance().MySqlError(mySqlException.Message, mySqlException.Code);
     }
     else
     {
         Logger.GetInstance().SqlError(exception.ToString());
     }
 }
예제 #4
0
        protected void LogSqlException(string query, DbException dbEx)
        {
            try
            {
                Trace.CorrelationManager.StartLogicalOperation(_type);

                Trace.TraceError("Sql query failed: {0}", query);

                Trace.TraceError(dbEx.ToString());
            }
            finally
            {
                Trace.CorrelationManager.StopLogicalOperation();
            }
        }
 public override string ToString()
 {
     return(_exception.ToString());
 }