I'm using Spring Boot 1.5.3, Spring Data REST, Spring HATEOAS, Hibernate. Spring Data REST manage in a pretty way exceptions, returning a well formatted JSON object like this:
{
"timestamp": "2017-06-24T16:08:54.107+0000",
"status": 500,
"error": "Internal Server Error",
"exception": "org.springframework.dao.InvalidDataAccessApiUsageException",
"message": "org.hibernate.TransientPropertyValueException: Not-null property references a transient value - transient instance must be saved beforeQuery current operation : com.test.server.model.workflows.WorkSession.checkPoint -> com.test.server.model.checkpoints.CheckPoint; nested exception is java.lang.IllegalStateException: org.hibernate.TransientPropertyValueException: Not-null property references a transient value - transient instance must be saved beforeQuery current operation : com.test.server.model.workflows.WorkSession.checkPoint -> com.test.server.model.checkpoints.CheckPoint",
"path": "/api/v1/workSessions/start"
}
I need to localize exception messages and I'd like to keep the same JSON format of Spring Data REST and take a look how they create the exception object. I'm looking for the code where the exception is created in source code but I am not able to find that. Maybe ExceptionMessage is useful but it has not the structure of the object that at the end arrive to the user.
Where is the point where the exception is created?