minor change to formatting of error messages

Signed-off-by: Gavin King <gavin@hibernate.org>
This commit is contained in:
Gavin King 2024-06-04 13:30:03 +02:00
parent 92f61c0956
commit 1a93a081e1
6 changed files with 15 additions and 16 deletions

View File

@ -6,7 +6,7 @@
*/
package org.hibernate;
import org.hibernate.pretty.MessageHelper;
import static org.hibernate.pretty.MessageHelper.infoString;
/**
* This exception is thrown when an operation would break session-scoped identity.
@ -57,6 +57,6 @@ public class NonUniqueObjectException extends HibernateException {
@Override
public String getMessage() {
return super.getMessage() + " : " + MessageHelper.infoString( entityName, identifier );
return super.getMessage() + ": " + infoString( entityName, identifier );
}
}

View File

@ -6,7 +6,7 @@
*/
package org.hibernate;
import org.hibernate.internal.util.StringHelper;
import static org.hibernate.internal.util.StringHelper.qualify;
/**
* Thrown when the (illegal) value of a property can not be persisted.
@ -47,6 +47,6 @@ public class PropertyValueException extends HibernateException {
@Override
public String getMessage() {
return super.getMessage() + " : " + StringHelper.qualify( entityName, propertyName );
return super.getMessage() + ": " + qualify( entityName, propertyName );
}
}

View File

@ -6,7 +6,7 @@
*/
package org.hibernate;
import org.hibernate.pretty.MessageHelper;
import static org.hibernate.pretty.MessageHelper.infoString;
/**
* A specialized {@link StaleStateException} that carries information about
@ -38,7 +38,7 @@ public class StaleObjectStateException extends StaleStateException {
}
public String getMessage() {
return super.getMessage() + " : " + MessageHelper.infoString( entityName, identifier );
return super.getMessage() + ": " + infoString( entityName, identifier );
}
}

View File

@ -6,7 +6,7 @@
*/
package org.hibernate;
import org.hibernate.internal.util.StringHelper;
import static org.hibernate.internal.util.StringHelper.qualify;
/**
* Thrown when a property cannot be persisted because it is an association
@ -69,7 +69,7 @@ public class TransientPropertyValueException extends TransientObjectException {
@Override
public String getMessage() {
return super.getMessage() + " : "
+ StringHelper.qualify( propertyOwnerEntityName, propertyName ) + " -> " + transientEntityName;
return super.getMessage() + ": "
+ qualify( propertyOwnerEntityName, propertyName ) + " -> " + transientEntityName;
}
}

View File

@ -6,7 +6,7 @@
*/
package org.hibernate;
import org.hibernate.pretty.MessageHelper;
import static org.hibernate.pretty.MessageHelper.infoString;
/**
* Thrown when Hibernate could not resolve an object by id, especially when
@ -60,7 +60,7 @@ public class UnresolvableObjectException extends HibernateException {
@Override
public String getMessage() {
return super.getMessage() + ": " + MessageHelper.infoString( entityName, identifier );
return super.getMessage() + ": " + infoString( entityName, identifier );
}
}

View File

@ -28,11 +28,10 @@ public class MappingException extends org.hibernate.MappingException {
@Override
public String getMessage() {
String message = super.getMessage();
if (origin != null) {
message += " : origin(" + origin.getName() + ")";
}
return message;
final String message = super.getMessage();
return origin != null
? message + " [" + origin.getName() + "]"
: message;
}
public Origin getOrigin() {