- /// This exception will be thrown either by O/R mapping tools or by custom DAO - /// implementations. - ///
- ///+ /// This exception will be thrown either by O/R mapping tools or by custom DAO + /// implementations. + ///
+ ///null to indicate that no exception match has been found and that
/// fallback translation should kick in.
///
- protected virtual DataAccessException DoTranslate(string task, string sql, string errorCode, Exception exception)
- {
- // First, try custom translation from overridden method.
- DataAccessException dex = TranslateException(task, sql, errorCode, exception);
- if (dex != null)
- {
- return dex;
- }
-
-
- if (errorCodes != null)
- {
-
- if (errorCode != null)
- {
- if (Array.IndexOf(errorCodes.BadSqlGrammarCodes, errorCode) >= 0)
- {
- LogTranslation(task, sql, errorCode, exception, false);
- return new BadSqlGrammarException(task, sql, exception);
- }
- else if (Array.IndexOf(errorCodes.InvalidResultSetAccessCodes, errorCode) >= 0)
- {
- LogTranslation(task, sql, errorCode, exception, false);
- return new InvalidResultSetAccessException(task, sql, exception);
+ protected virtual DataAccessException DoTranslate(string task, string sql, string errorCode, Exception exception)
+ {
+ // First, try custom translation from overridden method.
+ DataAccessException dex = TranslateException(task, sql, errorCode, exception);
+ if (dex != null)
+ {
+ return dex;
+ }
+
+
+ if (errorCodes != null)
+ {
+
+ if (errorCode != null)
+ {
+ if (Array.IndexOf(errorCodes.BadSqlGrammarCodes, errorCode) >= 0)
+ {
+ LogTranslation(task, sql, errorCode, exception, false);
+ return new BadSqlGrammarException(task, sql, exception);
+ }
+ else if (Array.IndexOf(errorCodes.InvalidResultSetAccessCodes, errorCode) >= 0)
+ {
+ LogTranslation(task, sql, errorCode, exception, false);
+ return new InvalidResultSetAccessException(task, sql, exception);
}
else if (Array.IndexOf(errorCodes.DuplicateKeyCodes, errorCode) >= 0)
{
LogTranslation(task, sql, errorCode, exception, false);
return new DuplicateKeyException(task, sql, exception);
- }
- else if (Array.IndexOf(errorCodes.DataAccessResourceFailureCodes, errorCode) >= 0)
- {
- LogTranslation(task, sql, errorCode, exception, false);
- return new DataAccessResourceFailureException(BuildMessage(task, sql, exception), exception);
- }
- else if (Array.IndexOf(errorCodes.PermissionDeniedCodes, errorCode) >= 0)
- {
- LogTranslation(task, sql, errorCode, exception, false);
- return new PermissionDeniedDataAccessException(BuildMessage(task, sql, exception), exception);
- }
- else if (Array.IndexOf(errorCodes.DataIntegrityViolationCodes, errorCode) >= 0)
- {
- LogTranslation(task, sql, errorCode, exception, false);
- return new DataIntegrityViolationException(BuildMessage(task, sql, exception), exception);
- }
- else if (Array.IndexOf(errorCodes.CannotAcquireLockCodes, errorCode) >= 0)
- {
- LogTranslation(task, sql, errorCode, exception, false);
- return new CannotAcquireLockException(BuildMessage(task, sql, exception), exception);
- }
- else if (Array.IndexOf(errorCodes.DeadlockLoserCodes, errorCode) >= 0)
- {
- LogTranslation(task, sql, errorCode, exception, false);
- return new DeadlockLoserDataAccessException(BuildMessage(task, sql, exception), exception);
- }
- else if (Array.IndexOf(errorCodes.CannotSerializeTransactionCodes, errorCode) >= 0)
- {
- LogTranslation(task, sql, errorCode, exception, false);
- return new CannotSerializeTransactionException(BuildMessage(task, sql, exception), exception);
- }
- }
- }
- return null;
- }
-
- /// null.
- /// The error code extracted from the generic data access exception for
- /// a particular provider.
- /// The exception thrown from a data access operation.
- /// null.
+ /// The error code extracted from the generic data access exception for
+ /// a particular provider.
+ /// The exception thrown from a data access operation.
+ ///