public Exception Map(Exception ex) { var updateEx = ex as DbUpdateException; if (updateEx == null) return ex; var nmemEx = ex.GetInnerExceptionOrDefault<NMemory.Exceptions.NMemoryException>(); if (nmemEx != null && typeof(NMemory.Exceptions.MultipleUniqueKeyFoundException).IsAssignableFrom(nmemEx.GetType())) { return new DuplicatedEntryException(ex); } return ex; }
public Exception Map(Exception ex) { var updateEx = ex as DbUpdateException; if (updateEx == null) return ex; var sqlEx = ex.GetInnerExceptionOrDefault<SqlException>(); if (sqlEx != null && sqlEx.Number.In(2601, 2627)) { // 2601: http://technet.microsoft.com/en-us/library/ms151779(v=sql.105).aspx // 2627: http://technet.microsoft.com/en-us/library/ms151757(v=sql.105).aspx return new DuplicatedEntryException(ex); } return ex; }