270. Using the catchError Operator
Jul 21, 2026 06:05
· 2:13
· English
· Whisper Turbo
· 2 স্পিকার
এই ট্ৰান্সক্ৰিপ্টৰ মেয়াদ শেষ হয় 7 দিন
স্থায়ী সংৰক্ষণৰ বাবে উন্নীত কৰক →
অকল প্ৰদৰ্শন কৰা হৈছে
0:02
S…
Speaker 2 (270. Using the catchError Operator)
No matter how you handle your error,
0:04
S…
Speaker 2 (270. Using the catchError Operator)
what can be useful is a special operator that can
0:08
S…
Speaker 2 (270. Using the catchError Operator)
assist you with handling errors.
0:10
S…
Speaker 2 (270. Using the catchError Operator)
And that special operator needs to be imported from rxjs
0:14
S…
Speaker 2 (270. Using the catchError Operator)
operators and it's named catch error and it does exactly what the
0:18
S…
Speaker 2 (270. Using the catchError Operator)
name suggests.
0:19
S…
Speaker 2 (270. Using the catchError Operator)
Now let's say here,
0:21
S…
Speaker 2 (270. Using the catchError Operator)
when we fetch posts where we already pipe some data,
0:25
S…
Speaker 2 (270. Using the catchError Operator)
we got an error and we want to handle
0:29
S…
Speaker 1 (270. Using the catchError Operator)
that.
0:30
S…
Speaker 2 (270. Using the catchError Operator)
Now we can simply add the catch error operator here.
0:34
S…
Speaker 2 (270. Using the catchError Operator)
We get our error response in here.
0:36
S…
Speaker 2 (270. Using the catchError Operator)
So we get exactly the same data we would get
0:40
S…
Speaker 2 (270. Using the catchError Operator)
in that second argument of the subscribe method.
0:45
S…
Speaker 2 (270. Using the catchError Operator)
And in here,
0:46
S…
Speaker 2 (270. Using the catchError Operator)
you could now do stuff like send to analytics server
0:50
S…
Speaker 2 (270. Using the catchError Operator)
or anything like that.
0:51
S…
Speaker 2 (270. Using the catchError Operator)
So some generic error handling task you might wanna do.
0:54
S…
Speaker 2 (270. Using the catchError Operator)
Maybe not related to the UI.
0:57
S…
Speaker 2 (270. Using the catchError Operator)
Though of course you could use the subject and next the error message
1:01
S…
Speaker 1 (270. Using the catchError Operator)
here too.
1:01
S…
Speaker 2 (270. Using the catchError Operator)
But maybe you have some behind the scenes stuff you want to do when an error occurs.
1:06
S…
Speaker 2 (270. Using the catchError Operator)
Log it somewhere,
1:07
S…
Speaker 2 (270. Using the catchError Operator)
send it to your own server,
1:08
S…
Speaker 2 (270. Using the catchError Operator)
your analytics server,
1:10
S…
Speaker 2 (270. Using the catchError Operator)
anything like that.
1:11
S…
Speaker 2 (270. Using the catchError Operator)
And once you're done handling that error,
1:13
S…
Speaker 2 (270. Using the catchError Operator)
you should pass it on though.
1:15
S…
Speaker 2 (270. Using the catchError Operator)
It definitely needs to be able to reach subscribe.
1:18
S…
Speaker 2 (270. Using the catchError Operator)
Just as you need to pass something here in map as well.
1:21
S…
Speaker 2 (270. Using the catchError Operator)
So we also now need to create a new
1:25
S…
Speaker 2 (270. Using the catchError Operator)
observable that wraps that error.
1:27
S…
Speaker 2 (270. Using the catchError Operator)
And for that,
1:28
S…
Speaker 2 (270. Using the catchError Operator)
you can import something from RxJS and that something is throw
1:33
S…
Speaker 1 (270. Using the catchError Operator)
error.
1:33
S…
Speaker 2 (270. Using the catchError Operator)
And that is a function that will yield a new observable and
1:37
S…
Speaker 2 (270. Using the catchError Operator)
it yields a new observable by wrapping an error.
1:41
S…
Speaker 2 (270. Using the catchError Operator)
So here we can now throw the...
1:45
S…
Speaker 2 (270. Using the catchError Operator)
Error response,
1:46
S…
Speaker 2 (270. Using the catchError Operator)
you could also throw a new custom error which you generated whatever
1:50
S…
Speaker 1 (270. Using the catchError Operator)
you want.
1:52
S…
Speaker 1 (270. Using the catchError Operator)
Important,
1:53
S…
Speaker 2 (270. Using the catchError Operator)
you need to return that observable which is created by throw
1:57
S…
Speaker 1 (270. Using the catchError Operator)
error.
1:57
S…
Speaker 2 (270. Using the catchError Operator)
And now with that,
1:59
S…
Speaker 2 (270. Using the catchError Operator)
this of course doesn't do anything useful here,
2:01
S…
Speaker 2 (270. Using the catchError Operator)
but it's just an idea that you could consider using catch
2:06
S…
Speaker 2 (270. Using the catchError Operator)
error if you have some generic error handling task you also
2:10
S…
Speaker 2 (270. Using the catchError Operator)
wanna execute.
এই অনুলিপি AI (স্বয়ংক্ৰিয় কথোপকথন স্বীকৃতি) দ্বাৰা সৃষ্টি কৰা হৈছে। ইয়াৰ অন্তৰ্গত ত্ৰুটি থাকিব পাৰে - গুৰুত্বপূৰ্ণ ব্যৱহাৰৰ বাবে মূল অডিঅ'ৰ সৈতে পৰীক্ষা কৰক। AI নীতি
সাৰাংশ
এই ট্ৰান্সক্ৰিপ্টৰ AI সাৰাংশ সৃষ্টি কৰিবলৈ সাৰাংশ ক্লিক কৰক।
সাৰাংশ...
এই অনুলিপিৰ বিষয়ে AI ক প্ৰশ্ন কৰক
এই অনুবাদৰ বিষয়ে যিকোনো প্ৰশ্ন কৰক — AI-এ প্ৰযোজ্য অংশসমূহ বিচাৰি পাব আৰু উত্তৰ দিব।