Skip to content

Commit c9fc5c3

Browse files
authored
Merge pull request #84 from TevaHenry/master
Error handling, "try..catch"
2 parents 1aa6187 + 8f4fd46 commit c9fc5c3

File tree

3 files changed

+183
-183
lines changed

3 files changed

+183
-183
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+
La différence devient évidente quand on regarde le code dans une fonction.
22

3-
The behavior is different if there's a "jump out" of `try..catch`.
3+
Le comportement est différent s'il y a un "saut" en dehors de `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+
Par exemple, quand il y a un `return` dans `try..catch`. La clause `finally` fonctionne en cas de *toute* sortie de` try..catch`, même via l'instruction `return`: juste après la fin de `try..catch`, mais avant que le code appelant obtienne le contrôle.
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+
...Ou quand il y a un `throw`, comme ici:
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+
C'est `finally` qui garantit le nettoyage ici. Si nous mettons simplement le code à la fin de `f`, il ne fonctionnerait pas dans ces situations.

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

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,11 @@ importance: 5
22

33
---
44

5-
# Finally or just the code?
5+
# Finally ou juste le code?
66

7-
Compare the two code fragments.
7+
Comparez les deux fragments de code.
88

9-
1. The first one uses `finally` to execute the code after `try..catch`:
9+
1. Le premier utilise `finally` pour exécuter le code après `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. Le deuxième fragment met le "cleanup" juste après `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+
Nous avons absolument besoin du nettoyage après le travail, peu importe qu'il y ait une erreur ou non.
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+
Y at-il un avantage ici à utiliser `finally` ou les deux fragments de code sont égaux? Si un tel avantage existe, donnez un exemple lorsque cela compte.

0 commit comments

Comments
 (0)