Practice · 1 of 2
Defensive Parsing
CHALLENGE
Difficulty: intermediate+25 XP
Implement parse_response(status, body) where body is bytes: 204 → {}; non-JSON body → raise ApiError('non-JSON response'); status >= 400 → raise ApiError containing the status; else return parsed JSON.
Press Submit to check your solution.
Back to lesson: Practice: Client Behavior Drills