HHH-10419 Factor converter instantiation exception error logic
This commit is contained in:
parent
e65a883761
commit
bb7cb7636b
|
@ -81,10 +81,7 @@ public abstract class AbstractPropertyHolder implements PropertyHolder {
|
|||
return makeAttributeConverterDescriptor( info );
|
||||
}
|
||||
catch (Exception e) {
|
||||
throw new IllegalStateException(
|
||||
String.format( "Unable to instantiate AttributeConverter [%s", info.getConverterClass().getName() ),
|
||||
e
|
||||
);
|
||||
throw buildExceptionFromInstantiationError( info, e );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -96,6 +93,13 @@ public abstract class AbstractPropertyHolder implements PropertyHolder {
|
|||
.findAutoApplyConverterForAttribute( property, context );
|
||||
}
|
||||
|
||||
protected IllegalStateException buildExceptionFromInstantiationError(AttributeConversionInfo info, Exception e) {
|
||||
return new IllegalStateException(
|
||||
String.format( "Unable to instantiate AttributeConverter [%s]", info.getConverterClass().getName() ),
|
||||
e
|
||||
);
|
||||
}
|
||||
|
||||
protected AttributeConverterDescriptor makeAttributeConverterDescriptor(AttributeConversionInfo conversion) {
|
||||
try {
|
||||
AttributeConverterDefinition definition = new AttributeConverterDefinition( conversion.getConverterClass().newInstance(), false );
|
||||
|
|
|
@ -356,10 +356,7 @@ public class CollectionPropertyHolder extends AbstractPropertyHolder {
|
|||
return makeAttributeConverterDescriptor( info );
|
||||
}
|
||||
catch (Exception e) {
|
||||
throw new IllegalStateException(
|
||||
String.format( "Unable to instantiate AttributeConverter [%s", info.getConverterClass().getName() ),
|
||||
e
|
||||
);
|
||||
throw buildExceptionFromInstantiationError( info, e );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -416,10 +413,7 @@ public class CollectionPropertyHolder extends AbstractPropertyHolder {
|
|||
return makeAttributeConverterDescriptor( info );
|
||||
}
|
||||
catch (Exception e) {
|
||||
throw new IllegalStateException(
|
||||
String.format( "Unable to instantiate AttributeConverter [%s", info.getConverterClass().getName() ),
|
||||
e
|
||||
);
|
||||
throw buildExceptionFromInstantiationError( info, e );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue