Skip to content

Commit f1862aa

Browse files
committed
translate 1-try-catch
1 parent 13fa1c5 commit f1862aa

File tree

3 files changed

+110
-109
lines changed

3 files changed

+110
-109
lines changed

1-js/10-error-handling/1-try-catch/1-finally-or-code-after/solution.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1-
The difference becomes obvious when we look at the code inside a function.
1+
Perbedaannya menjadi jelas ketika kita melihat kode di dalam suatu fungsi.
22

3-
The behavior is different if there's a "jump out" of `try..catch`.
3+
Perilakunya berbeda jika ada lompatan keluar dari `try..catch`.
44

5-
For instance, when there's a `return` inside `try..catch`. The `finally` clause works in case of *any* exit from `try..catch`, even via the `return` statement: right after `try..catch` is done, but before the calling code gets the control.
5+
Misalnya, ketika ada `return` di dalam` try..catch`. Klausa `finally` berfungsi jika *ada* ya keluar dari` try..catch`, bahkan melalui pernyataan `return`: tepat setelah` try..catch` selesai, tetapi sebelum kode pemanggil mendapatkan kontrol.
66

77
```js run
88
function f() {
@@ -21,7 +21,7 @@ function f() {
2121
f(); // cleanup!
2222
```
2323

24-
...Or when there's a `throw`, like here:
24+
.. Atau ketika ada `throw`, seperti di sini:
2525

2626
```js run
2727
function f() {
@@ -44,4 +44,4 @@ function f() {
4444
f(); // cleanup!
4545
```
4646

47-
It's `finally` that guarantees the cleanup here. If we just put the code at the end of `f`, it wouldn't run in these situations.
47+
Bagian `finally` yang menjamin proses pembersihan di sini. Jika kita hanya meletakkan kode di akhir `f`, itu tidak akan berjalan dalam situasi ini.

1-js/10-error-handling/1-try-catch/1-finally-or-code-after/task.md

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
1-
importance: 5
1+
Nilai Penting: 5
22

33
---
44

5-
# Finally or just the code?
5+
# Finally atau hanya kode biasa?
66

7-
Compare the two code fragments.
7+
Bandingkan dua fragmen kode.
88

9-
1. The first one uses `finally` to execute the code after `try..catch`:
9+
1. Yang pertama menggunakan `finally` untuk mengeksekusi kode setelah` try..catch`:
1010

1111
```js
1212
try {
@@ -19,7 +19,7 @@ Compare the two code fragments.
1919
*/!*
2020
}
2121
```
22-
2. The second fragment puts the cleaning right after `try..catch`:
22+
2. Fragmen kedua melakukan pembersihan tepat setelah `try..catch`:
2323

2424
```js
2525
try {
@@ -33,6 +33,6 @@ Compare the two code fragments.
3333
*/!*
3434
```
3535

36-
We definitely need the cleanup after the work, doesn't matter if there was an error or not.
36+
Kita pasti membutuhkan pembersihan setelah pekerjaan, tidak masalah apakah ada kesalahan atau tidak.
3737

38-
Is there an advantage here in using `finally` or both code fragments are equal? If there is such an advantage, then give an example when it matters.
38+
Apakah ada keuntungan di sini dalam menggunakan `finally` atau kedua fragmen kode sama? Jika ada keuntungan seperti itu, berikan contoh ketika itu penting.

0 commit comments

Comments
 (0)