in my case this exception message is thrown cos PSQL was localized as cyrillic. So to make an application catch the exception correctly i had to change exception pattern. There are two ways to do it:
in web-app.properties add cuba.uniqueConstraintViolationPattern = ERROR: duplicate key value violates unique constraint "(.+)". This pattern will extract idx_sec_user_uniq_login from the message and it could be localized in core/messages.properties bundle.
in a running app go to Administration -> Application properties and do the same thing - find the key cuba.uniqueConstraintViolationPattern and change its value to a needed error pattern.