From bf8e099b9c8b3c60d60b3712b4fc97b052c39887 Mon Sep 17 00:00:00 2001 From: julieng Date: Tue, 3 Aug 2021 08:03:23 +0200 Subject: convert content to md --- .../reference/global_objects/syntaxerror/index.md | 127 ++++++++------------- 1 file changed, 50 insertions(+), 77 deletions(-) (limited to 'files/fr/web/javascript/reference/global_objects/syntaxerror') diff --git a/files/fr/web/javascript/reference/global_objects/syntaxerror/index.md b/files/fr/web/javascript/reference/global_objects/syntaxerror/index.md index bddaea8370..8e02ba78e1 100644 --- a/files/fr/web/javascript/reference/global_objects/syntaxerror/index.md +++ b/files/fr/web/javascript/reference/global_objects/syntaxerror/index.md @@ -10,55 +10,52 @@ tags: translation_of: Web/JavaScript/Reference/Global_Objects/SyntaxError original_slug: Web/JavaScript/Reference/Objets_globaux/SyntaxError --- -
{{JSRef}}
+{{JSRef}} -

L'objet SyntaxError représente une erreur qui se produit lors de l'interprétation d'un code dont la syntaxe est invalide.

+L'objet **`SyntaxError`** représente une erreur qui se produit lors de l'interprétation d'un code dont la syntaxe est invalide. -

Description

+## Description -

Une exception SyntaxError est levée lorsque le moteur JavaScript rencontre des entités lexicales invalide ou dans un ordre invalide par rapport à la grammaire du langage.

+Une exception `SyntaxError` est levée lorsque le moteur JavaScript rencontre des entités lexicales invalide ou dans un ordre invalide par rapport à la grammaire du langage. -

Syntaxe

+## Syntaxe -
new SyntaxError([message[, nomFichier[, numLigne]]])
+ new SyntaxError([message[, nomFichier[, numLigne]]]) -

Paramètres

+### Paramètres -
-
message{{optional_inline}}
-
Une description, lisible par un humain, de l'erreur.
-
nomFichier {{optional_inline}}{{non-standard_inline}}
-
Le nom du fichier contenant le code provoquant l'erreur.
-
numLigne {{optional_inline}}{{non-standard_inline}}
-
Le numéro de la ligne du code qui a provoqué l'exception.
-
+- `message`{{optional_inline}} + - : Une description, lisible par un humain, de l'erreur. +- `nomFichier` {{optional_inline}}{{non-standard_inline}} + - : Le nom du fichier contenant le code provoquant l'erreur. +- `numLigne` {{optional_inline}}{{non-standard_inline}} + - : Le numéro de la ligne du code qui a provoqué l'exception. -

Propriétés

+## Propriétés -
-
{{jsxref("SyntaxError.prototype")}}
-
Cette méthode permet d'ajouter des propriétés aux instance de SyntaxError.
-
+- {{jsxref("SyntaxError.prototype")}} + - : Cette méthode permet d'ajouter des propriétés aux instance de `SyntaxError`. -

Méthodes

+## Méthodes -

L'objet global SyntaxError ne contient pas de méthodes directes. En revanche, il hérite de méthodes grâce à sa chaîne de prototypes.

+L'objet global `SyntaxError` ne contient pas de méthodes directes. En revanche, il hérite de méthodes grâce à sa chaîne de prototypes. -

Instances de SyntaxError

+## Instances de `SyntaxError` -

Propriétés

+### Propriétés -
{{page('/fr/docs/Web/JavaScript/Reference/Objets_globaux/SyntaxError/prototype', 'Propriétés')}}
+{{page('/fr/docs/Web/JavaScript/Reference/Objets_globaux/SyntaxError/prototype', 'Propriétés')}} -

Méthodes

+### Méthodes -
{{page('/fr/docs/Web/JavaScript/Reference/Objets_globaux/SyntaxError/prototype', 'Méthodes')}}
+{{page('/fr/docs/Web/JavaScript/Reference/Objets_globaux/SyntaxError/prototype', 'Méthodes')}} -

Exemples

+## Exemples -

Intercepter une exception SyntaxError

+### Intercepter une exception `SyntaxError` -
try {
+```js
+try {
   eval('toto truc');
 } catch (e) {
   console.log(e instanceof SyntaxError); // true
@@ -69,11 +66,12 @@ original_slug: Web/JavaScript/Reference/Objets_globaux/SyntaxError
   console.log(e.columnNumber);           // 4
   console.log(e.stack);                  // "@Scratchpad/1:2:3\n"
 }
-
+``` -

Créer une exception SyntaxError

+### Créer une exception `SyntaxError` -
try {
+```js
+try {
   throw new SyntaxError('Coucou', 'unFichier.js', 10);
 } catch (e) {
   console.log(e instanceof SyntaxError); // true
@@ -84,47 +82,22 @@ original_slug: Web/JavaScript/Reference/Objets_globaux/SyntaxError
   console.log(e.columnNumber);           // 0
   console.log(e.stack);                  // "@Scratchpad/2:11:9\n"
 }
-
- -

Spécifications

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
SpécificationStatutCommentaires
{{SpecName('ES3')}}{{Spec2('ES3')}}Définition initiale.
{{SpecName('ES5.1', '#sec-15.11.6.4', 'SyntaxError')}}{{Spec2('ES5.1')}} 
{{SpecName('ES6', '#sec-native-error-types-used-in-this-standard-syntaxerror', 'SyntaxError')}}{{Spec2('ES6')}} 
{{SpecName('ESDraft', '#sec-native-error-types-used-in-this-standard-syntaxerror', 'SyntaxError')}}{{Spec2('ESDraft')}} 
- -

Compatibilité des navigateurs

- -

{{Compat("javascript.builtins.SyntaxError")}}

- -

Voir aussi

- - +``` + +## Spécifications + +| Spécification | Statut | Commentaires | +| ------------------------------------------------------------------------------------------------------------------------------------ | ---------------------------- | -------------------- | +| {{SpecName('ES3')}} | {{Spec2('ES3')}} | Définition initiale. | +| {{SpecName('ES5.1', '#sec-15.11.6.4', 'SyntaxError')}} | {{Spec2('ES5.1')}} |   | +| {{SpecName('ES6', '#sec-native-error-types-used-in-this-standard-syntaxerror', 'SyntaxError')}} | {{Spec2('ES6')}} |   | +| {{SpecName('ESDraft', '#sec-native-error-types-used-in-this-standard-syntaxerror', 'SyntaxError')}} | {{Spec2('ESDraft')}} |   | + +## Compatibilité des navigateurs + +{{Compat("javascript.builtins.SyntaxError")}} + +## Voir aussi + +- {{jsxref("Error")}} +- {{jsxref("SyntaxError.prototype")}} -- cgit v1.2.3-54-g00ecf