SPRNET-1304 - Lack of error code information in translated exceptions
This commit is contained in:
@@ -99,7 +99,6 @@ namespace Spring.Data.Support
|
||||
set
|
||||
{
|
||||
dbProvider = value;
|
||||
fallbackTranslator = new FallbackExceptionTranslator();
|
||||
errorCodes = dbProvider.DbMetadata.ErrorCodes;
|
||||
|
||||
}
|
||||
@@ -165,8 +164,7 @@ namespace Spring.Data.Support
|
||||
sql = "";
|
||||
}
|
||||
string errorCode = ExtractErrorCode(exception);
|
||||
|
||||
// First, try custom translation from overridden method.
|
||||
|
||||
DataAccessException dex = DoTranslate(task, sql, errorCode, exception);
|
||||
if (dex != null)
|
||||
{
|
||||
@@ -176,7 +174,7 @@ namespace Spring.Data.Support
|
||||
// Looking for a fallback...
|
||||
if (log.IsDebugEnabled)
|
||||
{
|
||||
log.Debug("Unable to translate exception eith errorCode '" + errorCode + "', will use the fallback translator");
|
||||
log.Debug("Unable to translate exception with errorCode '" + errorCode + "', will use the fallback translator");
|
||||
}
|
||||
IAdoExceptionTranslator fallback = FallbackTranslator;
|
||||
if (fallback != null)
|
||||
|
||||
@@ -84,7 +84,7 @@ namespace Spring.Data
|
||||
/// <param name="sql">The offending SQL statment</param>
|
||||
/// <param name="ex">The root cause.</param>
|
||||
public UncategorizedAdoException(string task, string sql, string errorCode, Exception ex) : base(task + "; uncategorized DataException for SQL [" + sql + "]; " + "ErrorCode [" + errorCode + "]; " + ex.Message, ex)
|
||||
{
|
||||
{
|
||||
this.sql = sql;
|
||||
this.errorCode = errorCode;
|
||||
}
|
||||
@@ -106,9 +106,25 @@ namespace Spring.Data
|
||||
|
||||
#endregion
|
||||
|
||||
#region Properties
|
||||
|
||||
#endregion
|
||||
#region Properties
|
||||
|
||||
/// <summary>
|
||||
/// Return the underlying error code if available from the underlying provider.
|
||||
/// </summary>
|
||||
public string ErrorCode
|
||||
{
|
||||
get { return errorCode; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Return the SQL that resulted in this exception.
|
||||
/// </summary>
|
||||
public string Sql
|
||||
{
|
||||
get { return sql; }
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Methods
|
||||
|
||||
|
||||
@@ -171,6 +171,7 @@
|
||||
<ItemGroup>
|
||||
<EmbeddedResource Include="Data\AutoDeclarativeTxTests.xml" />
|
||||
<EmbeddedResource Include="Data\Common\AdditionalProviders.xml" />
|
||||
<EmbeddedResource Include="Data\Common\DbProviderFactoryTests.xml" />
|
||||
<Content Include="Spring.Data.Tests.dll.config" />
|
||||
<Content Include="Transaction\Config\TxNamespaceParserTests_TxAttributeDriven.xml" />
|
||||
<EmbeddedResource Include="Transaction\Interceptor\MatchAlwaysTransactionAttributeSourceTests.xml" />
|
||||
|
||||
Reference in New Issue
Block a user