๐งชTDD Challengeยทintermediateยทโฑ๏ธ 25โ40mยทโญ 175 XP
M-059Implement a Gateway Fallback Chain
Description
Nebula Corp's AI service went down for 2 hours when their primary LLM provider had an outage. Build a fallback chain that tries multiple providers in order. If the primary model fails, automatically try the next one. Track which model actually served the request and whether a fallback was used. The function should try each model in the chain until one succeeds or all fail.
Test Cases (3)
Falls back on failure
Should try next model when current fails
Input:testFallback()
Expected:CONTAINS:fallback-2
Tracks fallback status
Should report fallback=true when not using primary
Input:testFallbackStatus()
Expected:true
Reports all failures
Should throw with all error details
Input:testAllFail()
Expected:CONTAINS:All models failed
Related Lessons
Click Run / Check to validate your solution