mirror of
https://github.com/glen9527/Clean-Code-zh.git
synced 2025-12-17 18:54:23 +08:00
md 引入图片资源
This commit is contained in:
@@ -1,11 +1,8 @@
|
||||
# 第 7 章 Error Handling
|
||||
Image
|
||||
|
||||
Image
|
||||
|
||||
by Michael Feathers
|
||||
|
||||
Image
|
||||

|
||||
|
||||
It might seem odd to have a section about error handling in a book about clean code. Error handling is just one of those things that we all have to do when we program. Input can be abnormal and devices can fail. In short, things can go wrong, and when they do, we as programmers are responsible for making sure that our code does what it needs to do.
|
||||
|
||||
@@ -214,7 +211,7 @@ Often a single exception class is fine for a particular area of code. The inform
|
||||
DEFINE THE NORMAL FLOW
|
||||
If you follow the advice in the preceding sections, you’ll end up with a good amount of separation between your business logic and your error handling. The bulk of your code will start to look like a clean unadorned algorithm. However, the process of doing this pushes error detection to the edges of your program. You wrap external APIs so that you can throw your own exceptions, and you define a handler above your code so that you can deal with any aborted computation. Most of the time this is a great approach, but there are some times when you may not want to abort.
|
||||
|
||||
Image
|
||||

|
||||
|
||||
Let’s take a look at an example. Here is some awkward code that sums expenses in a billing application:
|
||||
```java
|
||||
|
||||
Reference in New Issue
Block a user