关于实体属性唯一错误的拦截

我在实体属性上设置了唯一,在界面上当用户输入了已经存在的值,会直接抛出错误:
PSQLException: 错误: 重复键违反唯一约束"idx_lims_sample_uk_code"
详细:键值"(code)=(06631A001)" 已经存在

我该在哪里拦截这个错误,以便换成自己的提示消息?

你好,

请先参考这里:
https://www.cuba-platform.com/discuss/t/unique-index-custom-exception-handler/963
https://doc.cuba-platform.cn/manual-7.0-chs/exceptionHandlers.html