Skip to content

Commit

Permalink
Update java-basic-questions-03.md
Browse files Browse the repository at this point in the history
  • Loading branch information
cxhello authored Feb 27, 2024
1 parent 4723458 commit aecb6e4
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion docs/java/basis/java-basic-questions-03.md
Original file line number Diff line number Diff line change
Expand Up @@ -218,7 +218,7 @@ catch (IOException e) {
- 不要把异常定义为静态变量,因为这样会导致异常栈信息错乱。每次手动抛出异常,我们都需要手动 new 一个异常对象抛出。
- 抛出的异常信息一定要有意义。
- 建议抛出更加具体的异常比如字符串转换为数字格式错误的时候应该抛出`NumberFormatException`而不是其父类`IllegalArgumentException`
- 使用日志打印异常之后就不要再抛出异常了(两者不要同时存在一段代码逻辑中)
- 避免重复记录日志:如果在捕获异常的地方已经记录了足够的信息(包括异常类型、错误信息和堆栈跟踪等),那么在业务代码中再次抛出这个异常时,就不应该再次记录相同的错误信息。重复记录日志会使得日志文件膨胀,并且可能会掩盖问题的实际原因,使得问题更难以追踪和解决
- ……

## 泛型
Expand Down

0 comments on commit aecb6e4

Please sign in to comment.