java 对外的异常信息常常需要转化的, 没有必要将错误信息直接抛出。例如

1. 实际没有信息。 假若是NPE, getMessage(), 将是没有信息。

2. 太过冗长, 例如一些数据库报错。错误信息很长。 例如:

\n### Error updating database.  Cause: java.sql.SQLIntegrityConstraintViolationException: Duplicate entry 'xxxx' for key 'xxxxxx'\n### The error may involve xxxxx.xxx.xxxbatchInsert-Inline\n### The error occurred while setting parameters\n### SQL: insert into xxx_table(xxx, xx, xxx) values                        (             ?,             ?,             ?,             ?,             ?,             ?,             ?,             ?,             ?,             ?,             ?,             ?,             ?,             ?,             ?,             ?,             ?,             ?,             ?,             ?,             ?,             ?,             ?,             ?,             ?,             ?,             ?,             ?,             NOW(),             NOW(),             0             )          ,              (             ?,             ?,             ?,             ?,             ?,             ?,             ?,             ?,             ?,             ?,             ?,             ?,             ?,             ?,             ?,             ?,             ?, 

 

3. 外部不好理解  或者不需要理解

 

标题1.1

标题1.1.1

相关文章:

  • 2022-12-23
  • 2021-10-24
  • 2022-12-23
  • 2022-02-24
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
猜你喜欢
  • 2021-04-04
  • 2022-12-23
  • 2021-06-05
  • 2021-05-16
  • 2022-12-23
  • 2021-06-07
  • 2021-06-14
相关资源
相似解决方案