|
|
|
@ -16,6 +16,7 @@ |
|
|
|
package org.springframework.data.document.mongodb; |
|
|
|
package org.springframework.data.document.mongodb; |
|
|
|
|
|
|
|
|
|
|
|
import com.mongodb.MongoException; |
|
|
|
import com.mongodb.MongoException; |
|
|
|
|
|
|
|
import com.mongodb.MongoException.CursorNotFound; |
|
|
|
import com.mongodb.MongoException.DuplicateKey; |
|
|
|
import com.mongodb.MongoException.DuplicateKey; |
|
|
|
import com.mongodb.MongoException.Network; |
|
|
|
import com.mongodb.MongoException.Network; |
|
|
|
import com.mongodb.MongoInternalException; |
|
|
|
import com.mongodb.MongoInternalException; |
|
|
|
@ -52,11 +53,14 @@ public class MongoExceptionTranslator implements PersistenceExceptionTranslator |
|
|
|
|
|
|
|
|
|
|
|
// All other MongoExceptions
|
|
|
|
// All other MongoExceptions
|
|
|
|
if (ex instanceof DuplicateKey) { |
|
|
|
if (ex instanceof DuplicateKey) { |
|
|
|
return new DataIntegrityViolationException(ex.getMessage(), ex); |
|
|
|
return new DuplicateKeyException(ex.getMessage(), ex); |
|
|
|
} |
|
|
|
} |
|
|
|
if (ex instanceof Network) { |
|
|
|
if (ex instanceof Network) { |
|
|
|
return new DataAccessResourceFailureException(ex.getMessage(), ex); |
|
|
|
return new DataAccessResourceFailureException(ex.getMessage(), ex); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
if (ex instanceof CursorNotFound) { |
|
|
|
|
|
|
|
return new DataAccessResourceFailureException(ex.getMessage(), ex); |
|
|
|
|
|
|
|
} |
|
|
|
if (ex instanceof MongoException) { |
|
|
|
if (ex instanceof MongoException) { |
|
|
|
int code = ((MongoException)ex).getCode(); |
|
|
|
int code = ((MongoException)ex).getCode(); |
|
|
|
if (code == 11000 || code == 11001) { |
|
|
|
if (code == 11000 || code == 11001) { |
|
|
|
|