Skip to content

Commit c5bcc3f

Browse files
authored
Merge pull request #294 from mrkrash/custom-errors/extending-error
Custom errors, extending Error
2 parents cf98758 + 4020644 commit c5bcc3f

File tree

4 files changed

+16
-16
lines changed

4 files changed

+16
-16
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 differenza diventa ovvia quando inseriamo il codice all'interno di una funzione.
22

3-
The behavior is different if there's a "jump out" of `try...catch`.
3+
Il comportamento è diverso se c'è una "uscita anticipata" dal `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+
Per esempio, quando c'è un `return` all'interno del `try...catch`. La clausola `finally` funziona *qualunque* sia la lcausa dell'uscita dal `try...catch`, anche tramite l'istruzione "return": appena il `try...catch` è terminato, ma prima che il codice richiamato prenda il controllo.
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+
...O quando si presenta un `throw`, come:
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+
È `finally` che garantisce la pulizia qui. Se inseriamo del codice alla fine di `f`, in queste situazioni, non verrà eseguito.

1-js/10-error-handling/2-custom-errors/1-format-error/solution.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,11 @@ class FormatError extends SyntaxError {
66
}
77
}
88

9-
let err = new FormatError("formatting error");
9+
let err = new FormatError("errore di formattazione");
1010

11-
alert( err.message ); // formatting error
11+
alert( err.message ); // errore di formattazione
1212
alert( err.name ); // FormatError
1313
alert( err.stack ); // stack
1414

15-
alert( err instanceof SyntaxError ); // true
15+
alert( err instanceof SyntaxError ); // vero
1616
```

1-js/10-error-handling/2-custom-errors/1-format-error/task.md

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

33
---
44

5-
# Inherit from SyntaxError
5+
# Eredita da SyntaxError
66

7-
Create a class `FormatError` that inherits from the built-in `SyntaxError` class.
7+
Crea una classe `FormatError` che eredita dalla classe incorporata `SyntaxError`.
88

9-
It should support `message`, `name` and `stack` properties.
9+
Dovrebbe supportare le proprietà `message`, `name` e `stack`.
1010

11-
Usage example:
11+
Esempio di esecuzione:
1212

1313
```js
1414
let err = new FormatError("formatting error");
1515

16-
alert( err.message ); // formatting error
16+
alert( err.message ); // Errore nella formattazione
1717
alert( err.name ); // FormatError
1818
alert( err.stack ); // stack
1919

20-
alert( err instanceof FormatError ); // true
21-
alert( err instanceof SyntaxError ); // true (because inherits from SyntaxError)
20+
alert( err instanceof FormatError ); // vero
21+
alert( err instanceof SyntaxError ); // vero (poiché eredita SyntaxError)
2222
```

1-js/10-error-handling/index.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
# Error handling
1+
# Gestione degli errori

0 commit comments

Comments
 (0)