There are other calls that have similar behaviour, it'd have been better to return a 'None' than an error.
I'd guess the network needs to have at least one switch to have a topology, so using the call on a system manager network, or an appliance-only network would cause the error.
There are two basic approaches...
i) figure out the rule and do API calls and code to determine which networks you can make the topology call on, i.e. look for networks that include at least one switch.
ii) just make the call on every network and ignore those that give the error.
I'd say ii) is the simplest approach, also more reliable as you can be sure you didn't inadvertently miss any topologies.