Région de recherche :

Date :

https://developer.mozilla.org › fr › docs › Web › JavaScript › Reference › Statements › try...catch

try...catch - JavaScript | MDN - MDN Web Docs

try...catch - JavaScript | MDN. L'instruction try...catch regroupe des instructions à exécuter et définit une réponse si l'une de ces instructions provoque une exception. Exemple interactif. Syntaxe. js. try { . instructions_try. } catch (exception_var_1 if condition_1) { // non-standard . instructions_catch_1. } . … catch (exception_var_2) { .

https://developer.mozilla.org › ... › Web › JavaScript › Reference › Global_Objects › Promise › catch

Promise.prototype.catch() - JavaScript | MDN - MDN Web Docs

The catch() method of Promise instances schedules a function to be called when the promise is rejected. It immediately returns another Promise object, allowing you to chain calls to other promise methods. It is a shortcut for then(undefined, onRejected).

https://www.w3schools.com › jsref › jsref_try_catch.asp

JavaScript try/catch/finally Statement - W3Schools

Learn how to use try, catch and finally statements to handle errors in JavaScript. See examples, syntax, parameters and browser support.

https://developer.mozilla.org › en-US › docs › Web › JavaScript › Reference › Statements › try...catch

try...catch - JavaScript | MDN - MDN Web Docs

The try...catch statement is comprised of a try block and either a catch block, a finally block, or both. The code in the try block is executed first, and if it throws an exception, the code in the catch block will be executed.

https://fr.javascript.info › try-catch

Gestion des erreurs, "try...catch" - JavaScript

La structure try...catch permet de gérer les erreurs d’exécution. Cela permet littéralement “d’essayer” (try) d’exécuter le code et “d’attraper” (catch) les erreurs qui peuvent s’y produire. La syntaxe est la suivante :

https://www.javascripttutorial.net › javascript-try-catch

JavaScript try…catch

This tutorial shows you how to use JavaScript try...catch statement to handle exceptions.

https://javascript.info › try-catch

Error handling, "try...catch" - The Modern JavaScript Tutorial

The try...catch construct has two main blocks: try, and then catch: try { // code... } catch (err) { // error handling } It works like this: First, the code in try {...} is executed. If there were no errors, then catch (err) is ignored: the execution reaches the end of try and goes on, skipping catch.

https://runebook.dev › fr › docs › javascript › global_objects › promise › catch

JavaScript - promise.catch [fr] - Runebook.dev

La méthode catch() des instances Promise planifie l'appel d'une fonction lorsque le promise est rejeté. Il renvoie immédiatement un objet Promise équivalent, vous permettant d'appeler chain vers d'autres méthodes promise . C'est un raccourci pour Promise.prototype.then(undefined, onRejected) . Try it. Syntax. js. promiseInstance. catch (onRejected)

https://javascript.info › promise-error-handling

Error handling with promises - The Modern JavaScript Tutorial

Learn how to use .catch and .then to handle errors in promise chains and executors. See examples of implicit and explicit try..catch, rethrowing and unhandled rejections.

https://masteringjs.io › tutorials › fundamentals › catch

The Promise `catch()` Function in JavaScript - Mastering JS

The catch() function tells JavaScript what function to call if the promise is rejected: const p = Promise.reject(new Error('Oops!')); p.catch(err => { err.message; // 'Oops!' }); With Promise Chaining. The major benefit of .catch() is that you can catch errors that occurred anywhere in a promise chain. const p = Promise.resolve('Na');