Skip to content

Commit 106cec8

Browse files
committed
Translate a part of article
1 parent c915cb5 commit 106cec8

1 file changed

Lines changed: 19 additions & 19 deletions

File tree

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

Lines changed: 19 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -580,17 +580,17 @@ function func() {
580580
در کد بالا، همیشه یک ارور از داخل `try` بیرون می‌آید چون `catch` وجود ندارد. اما قبل از اینکه جریان اجرای برنامه از تابع بیرون بیاید `finally` کار می‌کند.
581581
````
582582

583-
## Global catch
583+
## catch گلوبال
584584

585-
```warn header="Environment-specific"
586-
The information from this section is not a part of the core JavaScript.
585+
```warn header="مختص به محیط اجرا"
586+
اطلاعات این قسمت بخشی از جاوااسکریپت اصلی نیست.
587587
```
588588

589-
Let's imagine we've got a fatal error outside of `try...catch`, and the script died. Like a programming error or some other terrible thing.
589+
بیایید فرض کنیم که بیرون از `try...catch` یک ارور مهلک رخ داده است و اسکریپت می‌میرد. مثلا یک ارور برنامه‌نویسی یا یک چیز وحشتناک دیگر.
590590

591-
Is there a way to react on such occurrences? We may want to log the error, show something to the user (normally they don't see error messages), etc.
591+
آیا راهی برای واکنش به چنین اتفاقاتی وجود دارد؟ ممکن است ما بخواهیم ارور را رخدادنگاری کنیم، چیزی را به کاربر نمایش دهیم (معمولا آن‌ها پیام‌های ارور را نمی‌بینند) و غیره.
592592

593-
There is none in the specification, but environments usually provide it, because it's really useful. For instance, Node.js has [`process.on("uncaughtException")`](https://nodejs.org/api/process.html#process_event_uncaughtexception) for that. And in the browser we can assign a function to the special [window.onerror](mdn:api/GlobalEventHandlers/onerror) property, that will run in case of an uncaught error.
593+
درون مشخصات زبان راهی وجود ندارد اما محیط‌های اجرا معمولا راهی را فراهم می‌کنند چون این کار بسیار مفید است. برای مثال، Node.js برای این کار [`process.on("uncaughtException")`](https://nodejs.org/api/process.html#process_event_uncaughtexception) را دارد. و در مرورگر ما می‌توانیم به ویژگی مخصوص [window.onerror](mdn:api/GlobalEventHandlers/onerror) یک تابع اختصاص دهیم که در صورت رخ دادن یک ارور کنترل نشده اجرا شود.
594594

595595
The syntax:
596596

@@ -601,18 +601,18 @@ window.onerror = function(message, url, line, col, error) {
601601
```
602602

603603
`message`
604-
: Error message.
604+
: پیام ارور.
605605

606606
`url`
607-
: URL of the script where error happened.
607+
: URL اسکریپتی که ارور در آنجا رخ داده است.
608608

609609
`line`, `col`
610-
: Line and column numbers where error happened.
610+
: اعداد خط و ستون که ارور در آنجا رخ داده است.
611611

612612
`error`
613-
: Error object.
613+
: شیء ارور.
614614

615-
For instance:
615+
برای مثال:
616616

617617
```html run untrusted refresh height=1
618618
<script>
@@ -623,23 +623,23 @@ For instance:
623623
*/!*
624624
625625
function readData() {
626-
badFunc(); // Whoops, something went wrong!
626+
badFunc(); // !اوه، یک جای کار می‌لنگد
627627
}
628628
629629
readData();
630630
</script>
631631
```
632632

633-
The role of the global handler `window.onerror` is usually not to recover the script execution -- that's probably impossible in case of programming errors, but to send the error message to developers.
633+
معمولا نقش کنترل‌کننده گلوبال `window.onerror` این نیست که اجرای اسکریپت را ترمیم کند -- این موضوع در صورتی که ارور برنامه‌نویسی وجود داشته باشد احتمالا غیر ممکن است اما فرستادن پیام ارور به توسعه‌دهندگان ممکن است.
634634

635-
There are also web-services that provide error-logging for such cases, like <https://errorception.com> or <http://www.muscula.com>.
635+
همچنین سرویس‌های وب وجود دارند که رخدادنگاری ارور را برای چنین مواردی فراهم می‌کنند مانند <https://errorception.com> یا <http://www.muscula.com>.
636636

637-
They work like this:
637+
آن‌ها اینگونه کار می‌کنند:
638638

639-
1. We register at the service and get a piece of JS (or a script URL) from them to insert on pages.
640-
2. That JS script sets a custom `window.onerror` function.
641-
3. When an error occurs, it sends a network request about it to the service.
642-
4. We can log in to the service web interface and see errors.
639+
1. ما در سرویس ثبت نام می‌کنیم و از آن‌ها تکه‌ای از کد جاوااسکریپت (یا یک URL اسکریپت) برای اضافه کردن به صفحات دریافت می‌کنیم.
640+
2. آن کد جاوااسکریپت یک تابع `window.onerror` شخصی‌سازی شده را تنظیم می‌کند.
641+
3. زمانی که اروری رخ می‌دهد، این تابع درباره آن ارور، یک درخواست شبکه را به سرویس ارسال می‌کند.
642+
4. ما می‌توانیم وارد رابط وب سرویس شویم و ارورها را ببینیم.
643643

644644
## Summary
645645

0 commit comments

Comments
 (0)