0
votes

I am using Hibernate on Grails.

When I have field validation error, the exception message contains redundant message.

e.g

Provided id of the wrong type for class ad.Client. Expected: class java.lang.String, got class java.lang.Long; nested exception is org.hibernate.TypeMismatchException: Provided id of the wrong type for class org.ad.Client. Expected: class java.lang.String, got class java.lang.Long

when I have many field erros, I got a lot of unexpected redundant messages, why is this happening?

1
Can you show us what code you are using to print the error messages? - th3morg
@th3morg try{ new Client(params).save(failOnError:true); }catch(Exception ex){println ex.getMessage();} - t31321

1 Answers

0
votes

This is due to the way exceptions wrap each other, and how getMessage() works. Stack traces and exception messages of any kind often have some redundant information. Better too much than not enough :) It shouldn't really be an issue as this is for you, the developer. This isn't something you show externally, and not something to spend time on trying to improve.