Skip to content

Custom errors, extending Error #163

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 12 additions & 12 deletions 1-js/10-error-handling/1-try-catch/1-finally-or-code-after/task.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,37 +2,37 @@ importance: 5

---

# Finally or just the code?
# Finally o solamente il codice?

Compare the two code fragments.
Confronta i due frammenti di codice.

1. The first one uses `finally` to execute the code after `try..catch`:
1. Il primo utilizza `finally` per eseguire il codice dopo `try..catch`:

```js
try {
work work
lavoro lavoro
} catch (e) {
handle errors
gestisci gli errori
} finally {
*!*
cleanup the working space
ripulisci lo spazio di lavoro
*/!*
}
```
2. The second fragment puts the cleaning right after `try..catch`:
2. Il secondo posiziona la puliza subito dopo il `try..catch`:

```js
try {
work work
lavoro lavoro
} catch (e) {
handle errors
gestisci gli errori
}

*!*
cleanup the working space
ripulisci lo spazio di lavoro
*/!*
```

We definitely need the cleanup after the work, doesn't matter if there was an error or not.
Abbiamo decisamente bisogno di ripulire dopo il lavoro, sia che si verifichi un errore o meno.

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.
Esiste un vantaggio nell'usare `finally` o ambedue i frammenti di codice sono equivalenti? Se c'è qualche vantaggio, allora fornisci un esempio di quanto sia importante.
Loading