You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: 1-js/10-error-handling/1-try-catch/article.md
+19-19Lines changed: 19 additions & 19 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -580,17 +580,17 @@ function func() {
580
580
در کد بالا، همیشه یک ارور از داخل `try` بیرون میآید چون `catch` وجود ندارد. اما قبل از اینکه جریان اجرای برنامه از تابع بیرون بیاید `finally` کار میکند.
581
581
````
582
582
583
-
## Global catch
583
+
## catch گلوبال
584
584
585
-
```warn header="Environment-specific"
586
-
The information from this section is not a part of the core JavaScript.
585
+
```warn header="مختص به محیط اجرا"
586
+
اطلاعات این قسمت بخشی از جاوااسکریپت اصلی نیست.
587
587
```
588
588
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` یک ارور مهلک رخ داده است و اسکریپت میمیرد. مثلا یک ارور برنامهنویسی یا یک چیز وحشتناک دیگر.
590
590
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
+
آیا راهی برای واکنش به چنین اتفاقاتی وجود دارد؟ ممکن است ما بخواهیم ارور را رخدادنگاری کنیم، چیزی را به کاربر نمایش دهیم (معمولا آنها پیامهای ارور را نمیبینند) و غیره.
592
592
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)یک تابع اختصاص دهیم که در صورت رخ دادن یک ارور کنترل نشده اجرا شود.
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`این نیست که اجرای اسکریپت را ترمیم کند -- این موضوع در صورتی که ارور برنامهنویسی وجود داشته باشد احتمالا غیر ممکن است اما فرستادن پیام ارور به توسعهدهندگان ممکن است.
634
634
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>.
636
636
637
-
They work like this:
637
+
آنها اینگونه کار میکنند:
638
638
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.ما میتوانیم وارد رابط وب سرویس شویم و ارورها را ببینیم.
0 commit comments