public Exception Convert(AdoExceptionContextInfo contextInfo)
            {
                Exception result = null;
                var       sqle   = ADOExceptionHelper.ExtractDbException(contextInfo.SqlException) as SqlException;

                if (sqle != null)
                {
                    switch (sqle.Number)
                    {
                    case 547:
                        result = new ConstraintViolationException(
                            sqle.Message,
                            sqle,
                            contextInfo.Sql,
                            null);
                        break;

                    case 208:
                        result = new SQLGrammarException(
                            contextInfo.Message,
                            sqle,
                            contextInfo.Sql);
                        break;

                    case 3960:
                        result = new StaleObjectStateException(
                            contextInfo.EntityName,
                            contextInfo.EntityId);
                        break;
                    }
                }

                return(result ?? SQLStateConverter.HandledNonSpecificException(
                           contextInfo.SqlException,
                           contextInfo.Message,
                           contextInfo.Sql));
            }
Ejemplo n.º 2
0
 /// <summary>
 /// Initializes a new instance of the <see cref="HibernateOptimisticLockingFailureException"/> class.
 /// </summary>
 /// <param name="ex">The ex.</param>
 public HibernateOptimisticLockingFailureException(StaleObjectStateException ex) : base(ex.EntityName, ex.Identifier, ex.Message, ex)
 {
 }
 protected virtual void ManageStaleObjectState(StaleObjectStateException ese)
 {
     throw ese;
 }