Skip to content
Merged
Show file tree
Hide file tree
Changes from all 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
10 changes: 5 additions & 5 deletions 1-js/11-async/03-promise-chaining/01-then-vs-catch/solution.md
Original file line number Diff line number Diff line change
@@ -1,20 +1,20 @@
The short answer is: **no, they are not equal**:
پاسخ کوتاه: **خیر آن‌ها یکی نیستند**:

The difference is that if an error happens in `f1`, then it is handled by `.catch` here:
تفاوت این است که اگر اروری در `f1` رخ دهد، سپس اینجا توسط `.catch` مدیریت می‌شود:

```js run
promise
.then(f1)
.catch(f2);
```

...But not here:
...اما اینجا نه:

```js run
promise
.then(f1, f2);
```

That's because an error is passed down the chain, and in the second code piece there's no chain below `f1`.
به این دلیل که یک ارور به پایین زنجیره پاس داده می‌شود و در قطعه کد دوم پایین `f1` زنجیری وجود ندارد.

In other words, `.then` passes results/errors to the next `.then/catch`. So in the first example, there's a `catch` below, and in the second one there isn't, so the error is unhandled.
به عبارتی دیگر، `.then` نتایج/ارورها را به `.then/catch` بعدی پاس می‌دهد. پس در مثال اول، یک `catch` در پایین زنجیره وجود دارد و در مثال دوم وجود ندارد پس ارور مدیریت نشده باقی می‌ماند.
6 changes: 3 additions & 3 deletions 1-js/11-async/03-promise-chaining/01-then-vs-catch/task.md
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
# Promise: then versus catch
# Promise: then علیه catch

Are these code fragments equal? In other words, do they behave the same way in any circumstances, for any handler functions?
آیا این قطعه‌های کد یکی هستند؟ به عبارتی دیگر، آیا آن‌ها در هر شرایطی و به ازای هر تابع مدیریت‌کننده‌ای یکسان رفتار می‌کنند؟

```js
promise.then(f1).catch(f2);
```

Versus:
علیه:

```js
promise.then(f1, f2);
Expand Down
Loading