mhgrove/Empire

EntityManagerFactory should provide connection error cause exception

lbihanic opened this issue · 1 comments

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);
    

Thanks for reporting, this and the patch. Fixed.