check_response(code) that does nothing for code 200, raises PermissionError for 403, FileNotFoundError for 404, and RuntimeError(f'unexpected {code}') for anything else — driven by a dict mapping codes to exception classes, not an if/elif ladder for the known codes.check_response(404)
raises FileNotFoundError
The dict maps 404 to that class.
Store the classes themselves as values.
Instantiate at raise time: raise mapping[code]().