Status codes and error handling — what AI's API calls do when the wire blinks — step 8 of 9
Write a function classify(status) that takes an HTTP status code
and returns one of these strings:
"success"for any 2xx (200-299)"client-error"for any 4xx (400-499)"server-error"for any 5xx (500-599)"other"for anything else (including 1xx and 3xx)
Then loop over a list of test codes and print the result of each.
Expected output:
success
client-error
server-error
other
other
⌘↵ runs the editor.read, then continue.
Write a function classify(status) that takes an HTTP status code
and returns one of these strings:
"success"for any 2xx (200-299)"client-error"for any 4xx (400-499)"server-error"for any 5xx (500-599)"other"for anything else (including 1xx and 3xx)
Then loop over a list of test codes and print the result of each.
Expected output:
success
client-error
server-error
other
other
this step needs the editor
on desktop today; in the app (coming soon). save your spot and we'll bring you back here when you're ready.