Skip to main content

Practice ยท 1 of 2

Defensive Parsing

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.

Difficulty: intermediate

Back to lesson: Practice: Client Behavior Drills