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()); }
protected static void TreatDbException(DbException sqlx) { if (IsBusinessRuleException(sqlx)) { //Implementation of BusinessRulesException throw new Exception(ExtractErrorCode(sqlx), sqlx); } throw new Exception(sqlx.ToString(), sqlx); }
public static void HandleDbException(DbException exception) { if (exception is MySqlException mySqlException) { Logger.GetInstance().MySqlError(mySqlException.Message, mySqlException.Code); } else { Logger.GetInstance().SqlError(exception.ToString()); } }
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()); }