Skip to content
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

[Edit] JavaScript: try-catch (Shorten description) (#5766) #5781

Merged
merged 6 commits into from
Dec 10, 2024
Merged
Changes from 5 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
6 changes: 3 additions & 3 deletions content/javascript/concepts/try-catch/try-catch.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
---
Title: 'Try/Catch'
Description: 'The try...catch...finally statement defines one block of code to execute, a second block of code to be executed if the first block throws an exception, and a third block of code to be executed regardless of the error status. The catch and finally blocks of code are optional, but any try blocks must be followed by one or the other. javascript try { // Statements here are executed until an exception is thrown } catch (err) {'
Description: 'The `try...catch...finally` in JavaScript handles errors. try tests code, catch handles exceptions, and finally runs regardless of errors.'
Subjects:
- 'Web Development'
- 'Computer Science'
Expand All @@ -16,9 +16,9 @@ CatalogContent:
- 'paths/create-a-back-end-app-with-javascript'
---

The `try...catch...finally` statement defines one block of code to execute and test for possible errors, a second block of code to handle errors that may be present in the try block, and a third block of code to be executed regardless of the error status.
The **`try...catch...finally`** statement defines three blocks of code. The `try` block contains code that is tested for possible errors. If an error occurs, the `catch` block handles the exception. Finally, the `finally` block contains code that will execute regardless of whether an error occurred, ensuring that cleanup or final actions take place.

The `catch` and `finally` blocks of code are optional, but any `try` blocks must be followed by one or the other.
All `try` blocks must be followed by either `catch`, `finally`, or both.

## Syntax

Expand Down