Bird
0
0

Why is it important that Exception Mapping Interceptors return observables and do not convert them to promises or other types?

hard📝 Conceptual Q10 of 15
NestJS - Interceptors
Why is it important that Exception Mapping Interceptors return observables and do not convert them to promises or other types?
ABecause promises cannot handle errors
BBecause observables are faster than promises
CBecause converting to promises causes memory leaks
DBecause NestJS expects interceptors to return observables to maintain reactive flow
Step-by-Step Solution
Solution:
  1. Step 1: Understand NestJS interceptor expectations

    NestJS interceptors work with RxJS observables to handle asynchronous streams.
  2. Step 2: Importance of returning observables

    Returning observables preserves the reactive pipeline and allows operators like catchError to work properly.
  3. Final Answer:

    Because NestJS expects interceptors to return observables to maintain reactive flow -> Option D
  4. Quick Check:

    Interceptors must return observables for reactive flow [OK]
Quick Trick: Return observables in interceptors to keep reactive streams [OK]
Common Mistakes:
  • Converting observables to promises inside interceptors
  • Assuming promises handle errors better
  • Ignoring NestJS reactive design

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More NestJS Quizzes