Skip to content

Commit 40dd781

Browse files
committed
Translate a part of article
Line 667 and 626 need more attention.
1 parent 106cec8 commit 40dd781

1 file changed

Lines changed: 16 additions & 16 deletions

File tree

1-js/10-error-handling/1-try-catch/article.md

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -641,35 +641,35 @@ window.onerror = function(message, url, line, col, error) {
641641
3. زمانی که اروری رخ می‌دهد، این تابع درباره آن ارور، یک درخواست شبکه را به سرویس ارسال می‌کند.
642642
4. ما می‌توانیم وارد رابط وب سرویس شویم و ارورها را ببینیم.
643643

644-
## Summary
644+
## خلاصه
645645

646-
The `try...catch` construct allows to handle runtime errors. It literally allows to "try" running the code and "catch" errors that may occur in it.
646+
ساختار `try...catch` مدیریت ارورهای زمان اجرا را ممکن می‌سازد. این ساختار به طور لفظی اجازه می‌دهد که اجرای کد را «امتحان کنیم (try)» و ارورهایی که ممکن است درون آن رخ بدهند را «بگیریم (catch)».
647647

648-
The syntax is:
648+
سینتکس آن:
649649

650650
```js
651651
try {
652-
// run this code
652+
// این کد را اجرا کن
653653
} catch (err) {
654-
// if an error happened, then jump here
655-
// err is the error object
654+
// اگر اروری رخ داد، سپس به اینجا بپر
655+
// شیء ارور است err
656656
} finally {
657-
// do in any case after try/catch
657+
// این قسمت را انجام بده try/catch در هر صورت، بعد از
658658
}
659659
```
660660

661-
There may be no `catch` section or no `finally`, so shorter constructs `try...catch` and `try...finally` are also valid.
661+
ممکن است قسمت `catch` یا `finally` وجود نداشته باشد پس ساختارهای کوتاه‌تر `try...catch` و `try...finally` هم معتبر هستند.
662662

663-
Error objects have following properties:
663+
شیءهای ارور ویژگی‌های پایین را دارند:
664664

665-
- `message` -- the human-readable error message.
666-
- `name` -- the string with error name (error constructor name).
667-
- `stack` (non-standard, but well-supported) -- the stack at the moment of error creation.
665+
- `message` -- پیام ارور که برای انسان قابل خواندن است.
666+
- `name` -- رشته حاوی اسم ارور (اسم تابع سازنده ارور)
667+
- `stack` (استاندارد نیست، اما به خوبی پشتیبانی می‌شود) -- پشته‌ای که در لحظه ایجاد ارور وجود دارد.
668668

669-
If an error object is not needed, we can omit it by using `catch {` instead of `catch (err) {`.
669+
اگر شیء ارور نیاز نباشد، ما می‌توانیم با استفاده از `catch {` به جای `catch (err) {` آن را حذف کنیم.
670670

671-
We can also generate our own errors using the `throw` operator. Technically, the argument of `throw` can be anything, but usually it's an error object inheriting from the built-in `Error` class. More on extending errors in the next chapter.
671+
همچنین می‌توانیم با استفاده از عملگر `throw` ارورهای خودمان را ایجاد کنیم. از لحاظ فنی، آرگومان `throw` می‌تواند هر چیزی باشد اما معمولا یک شیء ارور است که از کلاس درون‌ساخت `Error` ارث‌بری می‌کند. اطلاعات بیشتری درباره تعمیم دادن ارورها در فصل بعدی وجود دارد.
672672

673-
*Rethrowing* is a very important pattern of error handling: a `catch` block usually expects and knows how to handle the particular error type, so it should rethrow errors it doesn't know.
673+
*پرتاب دوباره (rethrowing)* یک الگوی بسیار مهم در مدیریت ارور است: یک بلوک `catch` معمولا توقع یک نوع ارور خاص را دارد و می‌تواند چجوری آن را مدیریت کند پس باید ارورهایی که آن‌ها را نمی‌شناسد را دوباره پرتاب کند.
674674

675-
Even if we don't have `try...catch`, most environments allow us to setup a "global" error handler to catch errors that "fall out". In-browser, that's `window.onerror`.
675+
حتی اگر ما `try...catch` نداشته باشیم، اکثر محیط‌های اجرا به ما اجازه می‌دهند که یک کنترل‌کننده ارور «گلوبال» را برای گرفتن ارورهایی که «بیرون می‌افتند» بسازیم. در مرورگر `window.onerror` همان کنترل‌کننده است.

0 commit comments

Comments
 (0)