Bird
0
0

Identify the error in this pseudocode implementing a timeout:

medium📝 Analysis Q6 of 15
Microservices - Resilience Patterns
Identify the error in this pseudocode implementing a timeout:
try {
  response = callService(timeout=3000)
  print('Success')
} catch Exception {
  print('Timeout')
}
AMissing retry logic
BTimeout value is too high
CCatching generic Exception instead of TimeoutException
DNo error, code is correct
Step-by-Step Solution
Solution:
  1. Step 1: Analyze exception handling

    Catching generic Exception may hide other errors and is not specific to timeout.
  2. Step 2: Best practice for timeout

    TimeoutException should be caught specifically to handle timeout cases properly.
  3. Final Answer:

    Catching generic Exception instead of TimeoutException -> Option C
  4. Quick Check:

    Catch specific TimeoutException for timeouts [OK]
Quick Trick: Catch specific timeout exceptions, not generic ones [OK]
Common Mistakes:
MISTAKES
  • Using generic exception catch
  • Ignoring timeout exceptions
  • Assuming retry fixes timeout

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Microservices Quizzes