mhgrove/Empire — Issue #65: EntityManagerFactory should provide connection error cause exception
Author: lbihanic
Created: 2011-11-14 13:07:18+00:00
State: open

In case of connection error (ConnectException) while accessing a remote repository, EntityManagerFactory.newEntityManager() does not include the cause exception when throwing an IllegalStateException which make debugging network/firewall issues difficult.

The following patch fixed the issue:

diff --git a/core/src/com/clarkparsia/empire/impl/EntityManagerFactoryImpl.java b/core/src/com/clarkparsia/empire/impl/EntityManagerFactoryImpl.java
index 1c04936..4763604 100644
--- a/core/src/com/clarkparsia/empire/impl/EntityManagerFactoryImpl.java
+++ b/core/src/com/clarkparsia/empire/impl/EntityManagerFactoryImpl.java
@@ -111,7 +111,7 @@ public class EntityManagerFactoryImpl implements EntityManagerFactory {
return new EntityManagerImpl( (MutableDataSource) aSource);
}
catch (ConnectException e) {
-	throw new IllegalStateException("Could not connect to the data source");
+	throw new IllegalStateException("Could not connect to the data source", e);
}
catch (DataSourceException e) {
throw new IllegalArgumentException("There was an error creating the data source for the new EntityManager", e);