improve Jakarta Data exception messages
Signed-off-by: Gavin King <gavin@hibernate.org>
This commit is contained in:
parent
82518862ae
commit
0007f6a8a0
|
@ -279,14 +279,14 @@ public abstract class AbstractQueryMethod extends AbstractAnnotatedMethod {
|
|||
.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 @@ public abstract class AbstractQueryMethod extends AbstractAnnotatedMethod {
|
|||
.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 @@ public class IdFinderMethod extends AbstractFinderMethod {
|
|||
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 @@ public class LifecycleMethod extends AbstractAnnotatedMethod {
|
|||
.append(" exception) {\n")
|
||||
.append("\t\tthrow new ")
|
||||
.append(annotationMetaEntity.importType(convertedException))
|
||||
.append("(exception);\n")
|
||||
.append("(exception.getMessage(), exception);\n")
|
||||
.append("\t}\n");
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue