fix error messages in InstantiationExceptions

This commit is contained in:
Gavin 2022-12-24 11:09:54 +01:00 committed by Gavin King
parent 2355f98586
commit 608e4ef6d6
7 changed files with 14 additions and 14 deletions

View File

@ -52,7 +52,7 @@ public class EmbeddableInstantiatorPojoIndirecting extends AbstractPojoInstantia
return constructor.newInstance( values ); return constructor.newInstance( values );
} }
catch ( Exception e ) { catch ( Exception e ) {
throw new InstantiationException( "Could not instantiate entity: ", getMappedPojoClass(), e ); throw new InstantiationException( "Could not instantiate entity", getMappedPojoClass(), e );
} }
} }
@ -77,7 +77,7 @@ public class EmbeddableInstantiatorPojoIndirecting extends AbstractPojoInstantia
return constructor.newInstance( values ); return constructor.newInstance( values );
} }
catch ( Exception e ) { catch ( Exception e ) {
throw new InstantiationException( "Could not instantiate entity: ", getMappedPojoClass(), e ); throw new InstantiationException( "Could not instantiate entity", getMappedPojoClass(), e );
} }
} }
} }

View File

@ -50,7 +50,7 @@ public class EmbeddableInstantiatorPojoStandard extends AbstractPojoInstantiator
public Object instantiate(ValueAccess valuesAccess, SessionFactoryImplementor sessionFactory) { public Object instantiate(ValueAccess valuesAccess, SessionFactoryImplementor sessionFactory) {
if ( isAbstract() ) { if ( isAbstract() ) {
throw new InstantiationException( throw new InstantiationException(
"Cannot instantiate abstract class or interface: ", getMappedPojoClass() "Cannot instantiate abstract class or interface", getMappedPojoClass()
); );
} }
@ -76,7 +76,7 @@ public class EmbeddableInstantiatorPojoStandard extends AbstractPojoInstantiator
return instance; return instance;
} }
catch ( Exception e ) { catch ( Exception e ) {
throw new InstantiationException( "Could not instantiate entity: ", getMappedPojoClass(), e ); throw new InstantiationException( "Could not instantiate entity", getMappedPojoClass(), e );
} }
} }
} }

View File

@ -49,7 +49,7 @@ public class EmbeddableInstantiatorRecordIndirecting extends EmbeddableInstantia
return constructor.newInstance( values ); return constructor.newInstance( values );
} }
catch ( Exception e ) { catch ( Exception e ) {
throw new InstantiationException( "Could not instantiate entity: ", getMappedPojoClass(), e ); throw new InstantiationException( "Could not instantiate entity", getMappedPojoClass(), e );
} }
} }
@ -78,7 +78,7 @@ public class EmbeddableInstantiatorRecordIndirecting extends EmbeddableInstantia
return constructor.newInstance( values ); return constructor.newInstance( values );
} }
catch ( Exception e ) { catch ( Exception e ) {
throw new InstantiationException( "Could not instantiate entity: ", getMappedPojoClass(), e ); throw new InstantiationException( "Could not instantiate entity", getMappedPojoClass(), e );
} }
} }
} }

View File

@ -38,7 +38,7 @@ public class EmbeddableInstantiatorRecordStandard extends AbstractPojoInstantiat
return constructor.newInstance( valuesAccess.getValues() ); return constructor.newInstance( valuesAccess.getValues() );
} }
catch ( Exception e ) { catch ( Exception e ) {
throw new InstantiationException( "Could not instantiate entity: ", getMappedPojoClass(), e ); throw new InstantiationException( "Could not instantiate entity", getMappedPojoClass(), e );
} }
} }
} }

View File

@ -95,17 +95,17 @@ public class EntityInstantiatorPojoStandard extends AbstractEntityInstantiatorPo
@Override @Override
public Object instantiate(SessionFactoryImplementor sessionFactory) { public Object instantiate(SessionFactoryImplementor sessionFactory) {
if ( isAbstract() ) { if ( isAbstract() ) {
throw new InstantiationException( "Cannot instantiate abstract class or interface: ", getMappedPojoClass() ); throw new InstantiationException( "Cannot instantiate abstract class or interface", getMappedPojoClass() );
} }
else if ( constructor == null ) { else if ( constructor == null ) {
throw new InstantiationException( "No default constructor for entity: ", getMappedPojoClass() ); throw new InstantiationException( "No default constructor for entity", getMappedPojoClass() );
} }
else { else {
try { try {
return applyInterception( constructor.newInstance( (Object[]) null ) ); return applyInterception( constructor.newInstance( (Object[]) null ) );
} }
catch ( Exception e ) { catch ( Exception e ) {
throw new InstantiationException( "Could not instantiate entity: ", getMappedPojoClass(), e ); throw new InstantiationException( "Could not instantiate entity", getMappedPojoClass(), e );
} }
} }
} }

View File

@ -113,7 +113,7 @@ public class ManagedBeanRegistryInitiator implements StandardServiceInitiator<Ma
return (BeanContainer) containerClass.newInstance(); return (BeanContainer) containerClass.newInstance();
} }
catch (Exception e) { catch (Exception e) {
throw new InstantiationException( "Unable to instantiate specified BeanContainer : " + containerClass.getName(), containerClass, e ); throw new InstantiationException( "Unable to instantiate specified BeanContainer", containerClass, e );
} }
} }

View File

@ -90,20 +90,20 @@ public class PojoInstantiator implements Instantiator, Serializable {
public Object instantiate() { public Object instantiate() {
if ( isAbstract ) { if ( isAbstract ) {
throw new InstantiationException( "Cannot instantiate abstract class or interface: ", mappedClass ); throw new InstantiationException( "Cannot instantiate abstract class or interface", mappedClass );
} }
else if ( optimizer != null ) { else if ( optimizer != null ) {
return optimizer.newInstance(); return optimizer.newInstance();
} }
else if ( constructor == null ) { else if ( constructor == null ) {
throw new InstantiationException( "No default constructor for entity: ", mappedClass ); throw new InstantiationException( "No default constructor for entity", mappedClass );
} }
else { else {
try { try {
return applyInterception( constructor.newInstance( (Object[]) null ) ); return applyInterception( constructor.newInstance( (Object[]) null ) );
} }
catch ( Exception e ) { catch ( Exception e ) {
throw new InstantiationException( "Could not instantiate entity: ", mappedClass, e ); throw new InstantiationException( "Could not instantiate entity", mappedClass, e );
} }
} }
} }