aboutsummaryrefslogtreecommitdiff
path: root/files/fr/web/javascript/reference/objets_globaux/syntaxerror
diff options
context:
space:
mode:
authorPeter Bengtsson <mail@peterbe.com>2020-12-08 14:40:17 -0500
committerPeter Bengtsson <mail@peterbe.com>2020-12-08 14:40:17 -0500
commit33058f2b292b3a581333bdfb21b8f671898c5060 (patch)
tree51c3e392513ec574331b2d3f85c394445ea803c6 /files/fr/web/javascript/reference/objets_globaux/syntaxerror
parent8b66d724f7caf0157093fb09cfec8fbd0c6ad50a (diff)
downloadtranslated-content-33058f2b292b3a581333bdfb21b8f671898c5060.tar.gz
translated-content-33058f2b292b3a581333bdfb21b8f671898c5060.tar.bz2
translated-content-33058f2b292b3a581333bdfb21b8f671898c5060.zip
initial commit
Diffstat (limited to 'files/fr/web/javascript/reference/objets_globaux/syntaxerror')
-rw-r--r--files/fr/web/javascript/reference/objets_globaux/syntaxerror/index.html133
-rw-r--r--files/fr/web/javascript/reference/objets_globaux/syntaxerror/prototype/index.html89
2 files changed, 222 insertions, 0 deletions
diff --git a/files/fr/web/javascript/reference/objets_globaux/syntaxerror/index.html b/files/fr/web/javascript/reference/objets_globaux/syntaxerror/index.html
new file mode 100644
index 0000000000..2f362a9467
--- /dev/null
+++ b/files/fr/web/javascript/reference/objets_globaux/syntaxerror/index.html
@@ -0,0 +1,133 @@
+---
+title: SyntaxError
+slug: Web/JavaScript/Reference/Objets_globaux/SyntaxError
+tags:
+ - Error
+ - JavaScript
+ - Object
+ - Reference
+ - SyntaxError
+translation_of: Web/JavaScript/Reference/Global_Objects/SyntaxError
+---
+<div>{{JSRef}}</div>
+
+<p>L'objet <code><strong>SyntaxError</strong></code> représente une erreur qui se produit lors de l'interprétation d'un code dont la syntaxe est invalide.</p>
+
+<h2 id="Description">Description</h2>
+
+<p>Une exception <code>SyntaxError</code> est levée lorsque le moteur JavaScript rencontre des entités lexicales invalide ou dans un ordre invalide par rapport à la grammaire du langage.</p>
+
+<h2 id="Syntaxe">Syntaxe</h2>
+
+<pre class="syntaxbox"><code>new SyntaxError([<var>message</var>[, <var>nomFichier</var>[, <var>numLigne</var>]]])</code></pre>
+
+<h3 id="Paramètres">Paramètres</h3>
+
+<dl>
+ <dt><code>message</code>{{optional_inline}}</dt>
+ <dd>Une description, lisible par un humain, de l'erreur.</dd>
+ <dt><code>nomFichier</code> {{optional_inline}}{{non-standard_inline}}</dt>
+ <dd>Le nom du fichier contenant le code provoquant l'erreur.</dd>
+ <dt><code>numLigne</code> {{optional_inline}}{{non-standard_inline}}</dt>
+ <dd>Le numéro de la ligne du code qui a provoqué l'exception.</dd>
+</dl>
+
+<h2 id="Propriétés">Propriétés</h2>
+
+<dl>
+ <dt>{{jsxref("SyntaxError.prototype")}}</dt>
+ <dd>Cette méthode permet d'ajouter des propriétés aux instance de <code>SyntaxError</code>.</dd>
+</dl>
+
+<h2 id="Méthodes">Méthodes</h2>
+
+<p>L'objet global <code>SyntaxError</code> ne contient pas de méthodes directes. En revanche, il hérite de méthodes grâce à sa chaîne de prototypes.</p>
+
+<h2 id="Instances_de_SyntaxError">Instances de <code>SyntaxError</code></h2>
+
+<h3 id="Propriétés_2">Propriétés</h3>
+
+<div>{{page('/fr/docs/Web/JavaScript/Reference/Objets_globaux/SyntaxError/prototype', 'Propriétés')}}</div>
+
+<h3 id="Méthodes_2">Méthodes</h3>
+
+<div>{{page('/fr/docs/Web/JavaScript/Reference/Objets_globaux/SyntaxError/prototype', 'Méthodes')}}</div>
+
+<h2 id="Exemples">Exemples</h2>
+
+<h3 id="Intercepter_une_exception_SyntaxError">Intercepter une exception <code>SyntaxError</code></h3>
+
+<pre class="brush: js">try {
+ eval('toto truc');
+} catch (e) {
+ console.log(e instanceof SyntaxError); // true
+ console.log(e.message); // "missing ; before statement"
+ console.log(e.name); // "SyntaxError"
+ console.log(e.fileName); // "Scratchpad/1"
+ console.log(e.lineNumber); // 1
+ console.log(e.columnNumber); // 4
+ console.log(e.stack); // "@Scratchpad/1:2:3\n"
+}
+</pre>
+
+<h3 id="Créer_une_exception_SyntaxError">Créer une exception <code>SyntaxError</code></h3>
+
+<pre class="brush: js">try {
+ throw new SyntaxError('Coucou', 'unFichier.js', 10);
+} catch (e) {
+ console.log(e instanceof SyntaxError); // true
+ console.log(e.message); // "Coucou"
+ console.log(e.name); // "SyntaxError"
+ console.log(e.fileName); // "unFichier.js"
+ console.log(e.lineNumber); // 10
+ console.log(e.columnNumber); // 0
+ console.log(e.stack); // "@Scratchpad/2:11:9\n"
+}
+</pre>
+
+<h2 id="Spécifications">Spécifications</h2>
+
+<table class="standard-table">
+ <tbody>
+ <tr>
+ <th scope="col">Spécification</th>
+ <th scope="col">Statut</th>
+ <th scope="col">Commentaires</th>
+ </tr>
+ <tr>
+ <td>{{SpecName('ES3')}}</td>
+ <td>{{Spec2('ES3')}}</td>
+ <td>Définition initiale.</td>
+ </tr>
+ <tr>
+ <td>{{SpecName('ES5.1', '#sec-15.11.6.4', 'SyntaxError')}}</td>
+ <td>{{Spec2('ES5.1')}}</td>
+ <td> </td>
+ </tr>
+ <tr>
+ <td>{{SpecName('ES6', '#sec-native-error-types-used-in-this-standard-syntaxerror', 'SyntaxError')}}</td>
+ <td>{{Spec2('ES6')}}</td>
+ <td> </td>
+ </tr>
+ <tr>
+ <td>{{SpecName('ESDraft', '#sec-native-error-types-used-in-this-standard-syntaxerror', 'SyntaxError')}}</td>
+ <td>{{Spec2('ESDraft')}}</td>
+ <td> </td>
+ </tr>
+ </tbody>
+</table>
+
+<h2 id="Compatibilité_des_navigateurs">Compatibilité des navigateurs</h2>
+
+<div>
+<div class="hidden">Le tableau de compatibilité de cette page a été généré à partir de données structurées. Si vous souhaitez contribuer à ces données, n'hésitez pas à consulter <a href="https://github.com/mdn/browser-compat-data">https://github.com/mdn/browser-compat-data</a> et à nous envoyer une <em>pull request</em>.</div>
+
+<p>{{Compat("javascript.builtins.SyntaxError")}}</p>
+</div>
+
+<h2 id="Voir_aussi">Voir aussi</h2>
+
+<ul>
+ <li>{{jsxref("Error")}}</li>
+ <li>{{jsxref("SyntaxError.prototype")}}</li>
+</ul>
diff --git a/files/fr/web/javascript/reference/objets_globaux/syntaxerror/prototype/index.html b/files/fr/web/javascript/reference/objets_globaux/syntaxerror/prototype/index.html
new file mode 100644
index 0000000000..2256b66b87
--- /dev/null
+++ b/files/fr/web/javascript/reference/objets_globaux/syntaxerror/prototype/index.html
@@ -0,0 +1,89 @@
+---
+title: SyntaxError.prototype
+slug: Web/JavaScript/Reference/Objets_globaux/SyntaxError/prototype
+tags:
+ - Error
+ - JavaScript
+ - Propriété
+ - Prototype
+ - Reference
+ - SyntaxError
+translation_of: Web/JavaScript/Reference/Global_Objects/SyntaxError
+---
+<div>{{JSRef}}</div>
+
+<p>La propriété <code><strong>SyntaxError.prototype</strong></code> représente le prototype du constructeur {{jsxref("SyntaxError")}}.</p>
+
+<h2 id="Description">Description</h2>
+
+<p>Toutes les instances de {{jsxref("SyntaxError")}} héritent de <code>SyntaxError.prototype</code>. Le prototype peut être utilisé afin d'ajouter des propriétés ou des méthodes à toutes les instances.</p>
+
+<h2 id="Propriétés">Propriétés</h2>
+
+<dl>
+ <dt><code>SyntaxError.prototype.constructor</code></dt>
+ <dd>Définit la fonction qui a créé le prototype d'une instance.</dd>
+ <dt>{{jsxref("Error.prototype.message", "SyntaxError.prototype.message")}}</dt>
+ <dd>Un message d'erreur. Bien que ECMA-262 définisse que {{jsxref("SyntaxError")}} doit avoir une propriété <code>message</code> en propre, dans <a href="/fr/docs/SpiderMonkey">SpiderMonkey</a>, elle est héritée depuis {{jsxref("Error.prototype.message")}}.</dd>
+ <dt>{{jsxref("Error.prototype.name", "SyntaxError.prototype.name")}}</dt>
+ <dd>Un nom d'erreur. Propriété héritée depuis {{jsxref("Error")}}.</dd>
+ <dt>{{jsxref("Error.prototype.fileName", "SyntaxError.prototype.fileName")}}</dt>
+ <dd>Le chemin du fichier qui a causé l'erreur. Propriété héritée depuis {{jsxref("Error")}}.</dd>
+ <dt>{{jsxref("Error.prototype.lineNumber", "SyntaxError.prototype.lineNumber")}}</dt>
+ <dd>Le numéro de la ligne du fichier qui a causé l'erreur. Propriété héritée depuis {{jsxref("Error")}}.</dd>
+ <dt>{{jsxref("Error.prototype.columnNumber", "SyntaxError.prototype.columnNumber")}}</dt>
+ <dd>Le numéro de la colonne dans la ligne qui a causé l'erreur. Propriété héritée depuis {{jsxref("Error")}}.</dd>
+ <dt>{{jsxref("Error.prototype.stack", "SyntaxError.prototype.stack")}}</dt>
+ <dd>La pile d'appels (<em>stack trace</em>). Propriété héritée depuis {{jsxref("Error")}}.</dd>
+</dl>
+
+<h2 id="Méthodes">Méthodes</h2>
+
+<p>Bien que le prototype de {{jsxref("SyntaxError")}} ne possède pas de méthodes directes, les instances de {{jsxref("SyntaxError")}} héritent de certaines méthodes via la chaîne de prototypes.</p>
+
+<h2 id="Spécifications">Spécifications</h2>
+
+<table class="standard-table">
+ <tbody>
+ <tr>
+ <th scope="col">Spécification</th>
+ <th scope="col">Statut</th>
+ <th scope="col">Commentaires</th>
+ </tr>
+ <tr>
+ <td>{{SpecName('ES3')}}</td>
+ <td>{{Spec2('ES3')}}</td>
+ <td>Définition initiale.</td>
+ </tr>
+ <tr>
+ <td>{{SpecName('ES5.1', '#sec-15.11.7.6', 'NativeError.prototype')}}</td>
+ <td>{{Spec2('ES5.1')}}</td>
+ <td>Définie comme <code><em>NativeError</em>.prototype</code>.</td>
+ </tr>
+ <tr>
+ <td>{{SpecName('ES6', '#sec-nativeerror.prototype', 'NativeError.prototype')}}</td>
+ <td>{{Spec2('ES6')}}</td>
+ <td>Définie comme <code><em>NativeError</em>.prototype</code>.</td>
+ </tr>
+ <tr>
+ <td>{{SpecName('ESDraft', '#sec-nativeerror.prototype', 'NativeError.prototype')}}</td>
+ <td>{{Spec2('ESDraft')}}</td>
+ <td>Définie comme <code><em>NativeError</em>.prototype</code>.</td>
+ </tr>
+ </tbody>
+</table>
+
+<h2 id="Compatibilité_des_navigateurs">Compatibilité des navigateurs</h2>
+
+<div>
+<div class="hidden">Le tableau de compatibilité de cette page a été généré à partir de données structurées. Si vous souhaitez contribuer à ces données, n'hésitez pas à consulter <a href="https://github.com/mdn/browser-compat-data">https://github.com/mdn/browser-compat-data</a> et à nous envoyer une <em>pull request</em>.</div>
+
+<p>{{Compat("javascript.builtins.SyntaxError")}}</p>
+</div>
+
+<h2 id="Voir_aussi">Voir aussi</h2>
+
+<ul>
+ <li>{{jsxref("Error.prototype")}}</li>
+ <li>{{jsxref("Function.prototype")}}</li>
+</ul>