mirror of
https://github.com/hibernate/hibernate-orm
synced 2025-02-18 00:55:16 +00:00
improve Jakarta Data exception messages
Signed-off-by: Gavin King <gavin@hibernate.org>
This commit is contained in:
parent
23dc51d291
commit
04d22686bb
@ -279,14 +279,14 @@ void convertExceptions(StringBuilder declaration) {
|
||||
.append(" exception) {\n")
|
||||
.append("\t\tthrow new ")
|
||||
.append(annotationMetaEntity.importType("jakarta.data.exceptions.EmptyResultException"))
|
||||
.append("(exception);\n")
|
||||
.append("(exception.getMessage(), exception);\n")
|
||||
.append("\t}\n")
|
||||
.append("\tcatch (")
|
||||
.append(annotationMetaEntity.importType("jakarta.persistence.NonUniqueResultException"))
|
||||
.append(" exception) {\n")
|
||||
.append("\t\tthrow new ")
|
||||
.append(annotationMetaEntity.importType("jakarta.data.exceptions.NonUniqueResultException"))
|
||||
.append("(exception);\n")
|
||||
.append("(exception.getMessage(), exception);\n")
|
||||
.append("\t}\n");
|
||||
}
|
||||
declaration
|
||||
@ -295,7 +295,7 @@ void convertExceptions(StringBuilder declaration) {
|
||||
.append(" exception) {\n")
|
||||
.append("\t\tthrow new ")
|
||||
.append(annotationMetaEntity.importType("jakarta.data.exceptions.DataException"))
|
||||
.append("(exception);\n")
|
||||
.append("(exception.getMessage(), exception);\n")
|
||||
.append("\t}\n");
|
||||
}
|
||||
}
|
||||
|
@ -86,7 +86,11 @@ private void throwIfNull(StringBuilder declaration) {
|
||||
declaration
|
||||
.append("\t\tif (_result == null) throw new ")
|
||||
.append(annotationMetaEntity.importType("jakarta.data.exceptions.EmptyResultException"))
|
||||
.append("(new ")
|
||||
.append("(\"No '")
|
||||
.append(annotationMetaEntity.importType(entity))
|
||||
.append("' for given id [\" + ")
|
||||
.append(paramName)
|
||||
.append(" + \"]\",\n\t\t\t\tnew ")
|
||||
.append(annotationMetaEntity.importType("org.hibernate.ObjectNotFoundException"))
|
||||
.append("((Object) ")
|
||||
.append(paramName)
|
||||
|
@ -192,7 +192,7 @@ private void convertException(StringBuilder declaration, String exception, Strin
|
||||
.append(" exception) {\n")
|
||||
.append("\t\tthrow new ")
|
||||
.append(annotationMetaEntity.importType(convertedException))
|
||||
.append("(exception);\n")
|
||||
.append("(exception.getMessage(), exception);\n")
|
||||
.append("\t}\n");
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user