buildConstraintViolationWithTemplate('some message') does not work.
the above code will output whatever is defined in the default message.
the above code will ignore the message and default message and will out put the code with the fiull path and the name of the constraint prepended.
I wrote up a stackoverflow question here with more detail :
Windows 8.1 Pro