How to make a localized message for this kind of exception?

Hello, don’t you know how to make a localized message for this kind of exception?

    Exception: org.postgresql.util.PSQLException: ERROR: duplicate key value violates unique constraint "idx_sec_user_uniq_login"
      Detail: Key (login_lc)=(user2.user2) already exists.

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:

  1. 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.
  2. 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.
2 Likes