Skip to content

Commit 7df6b26

Browse files
authored
Merge pull request hienvd#6 from hienvd/feature/8-error-handling
Translate 8-Error-Handling
2 parents 294d1ad + f188cf2 commit 7df6b26

File tree

1 file changed

+20
-21
lines changed

1 file changed

+20
-21
lines changed

README.md

Lines changed: 20 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ Original Repository: [ryanmcdermott/clean-code-javascript](https://github.com/ry
1010
5. [Classes](#classes)
1111
6. [Testing](#testing)
1212
7. [Concurrency](#concurrency)
13-
8. [Error Handling](#error-handling)
13+
8. [Xử lí lỗi](#xử-lí-lỗi)
1414
9. [Formatting](#formatting)
1515
10. [Viết chú thích](#viết-chú-thích)
1616
11. [Các ngôn ngữ khác](#các-ngôn-ngữ-khác)
@@ -1843,21 +1843,21 @@ async function getCleanCodeArticle() {
18431843
**[⬆ back to top](#mục-lục)**
18441844

18451845

1846-
## **Error Handling**
1847-
Thrown errors are a good thing! They mean the runtime has successfully
1848-
identified when something in your program has gone wrong and it's letting
1849-
you know by stopping function execution on the current stack, killing the
1850-
process (in Node), and notifying you in the console with a stack trace.
1846+
## **Xử lí lỗi**
1847+
Thông báo lỗi là một điều tốt! Nghĩa là chương trình của bạn nhận dạng
1848+
được khi có một cái gì đó chạy không đúng và nó sẽ cho bạn biết bằng việc
1849+
dừng chức năng mà nó đang thực thi, huỷ tiến trình (trong Node), và thông
1850+
báo cho bạn trong console với một stack để theo dấu.
18511851

1852-
### Don't ignore caught errors
1853-
Doing nothing with a caught error doesn't give you the ability to ever fix
1854-
or react to said error. Logging the error to the console (`console.log`)
1855-
isn't much better as often times it can get lost in a sea of things printed
1856-
to the console. If you wrap any bit of code in a `try/catch` it means you
1857-
think an error may occur there and therefore you should have a plan,
1858-
or create a code path, for when it occurs.
1852+
### Đừng bỏ qua những lỗi đã bắt được
1853+
Nếu không làm gì với lỗi đã bắt được, bạn sẽ không thể sửa hoặc phản ứng
1854+
lại được với lỗi đó. Ghi lỗi ra console (`console.log`) cũng không tốt hơn
1855+
bao nhiêu vì đa số nó có thể bị trôi mất trong một đống những thứ được hiển
1856+
thị ra ở console. Nếu bạn đặt bất cứ đoạn code nào trong một block `try/catch`,
1857+
tức là bạn nghĩ một lỗi có thể xảy ra ở đây, do đó bạn nên có một giải pháp
1858+
hoặc tạo một luồng code để xử lí lỗi khi nó xảy ra.
18591859

1860-
**Bad:**
1860+
**Không tốt:**
18611861
```javascript
18621862
try {
18631863
functionThatMightThrow();
@@ -1866,7 +1866,7 @@ try {
18661866
}
18671867
```
18681868

1869-
**Good:**
1869+
**Tốt:**
18701870
```javascript
18711871
try {
18721872
functionThatMightThrow();
@@ -1881,11 +1881,10 @@ try {
18811881
}
18821882
```
18831883

1884-
### Don't ignore rejected promises
1885-
For the same reason you shouldn't ignore caught errors
1886-
from `try/catch`.
1884+
### Đừng bỏ qua những promise bị lỗi (rejected)
1885+
Cùng nguyên nhân với phần trên.
18871886

1888-
**Bad:**
1887+
**Không tốt:**
18891888
```javascript
18901889
getdata()
18911890
.then((data) => {
@@ -1896,7 +1895,7 @@ getdata()
18961895
});
18971896
```
18981897

1899-
**Good:**
1898+
**Tốt:**
19001899
```javascript
19011900
getdata()
19021901
.then((data) => {
@@ -1913,7 +1912,7 @@ getdata()
19131912
});
19141913
```
19151914

1916-
**[back to top](#mục-lục)**
1915+
**[về trang chủ](#mục-lục)**
19171916

19181917

19191918
## **Formatting**

0 commit comments

Comments
 (0)