DATACMNS-374 - Improved error handling in case of a missing repository.

In Repositories.getCrudInvoker(…) we now throw an IllegalArgumentException if we cannot find an appropriate repository for the given domain class. Previously it just blew up with a NullPointerException without a clear error message.

Original pull request: #46.
This commit is contained in:
Thomas Darimont
2013-10-02 13:15:33 +02:00
committed by Oliver Gierke
parent 43b7a54294
commit 2d699b6b36
2 changed files with 24 additions and 0 deletions

View File

@@ -163,6 +163,8 @@ public class Repositories implements Iterable<Class<?>> {
RepositoryInformation information = getRepositoryInformationFor(domainClass);
Object repository = getRepositoryFor(domainClass);
Assert.notNull(repository, String.format("No repository found for domain class: %s", domainClass));
if (repository instanceof CrudRepository) {
return new CrudRepositoryInvoker<T>((CrudRepository<T, Serializable>) repository);
} else {