Enumerate all possible errors that can happen and handle them.
1x - Bad input
Error 10 - Bad URL
2x - DNS errors
Error 20 - Invalid domain name
Error 21 - timeout when resolving the DNS
3x - Connection errors
Error 30 - connection refused
Error 31 - connection dropped abruptly
4x - timeouts
Error 40 - timeout when trying to connect
Error 41 - timeout when reading headers
Error 42 - timeout when reading body
5x - resource limits
Error 50 - Response too big
Error 51 - Response took too long time
Notes
We don't have a way to identify Error 21 as socket.gethostbyname does't respect timeouts
Error 51 is different from timeout. It can happen that the server is giving data at very slow pace (one byte per second) without timing out. This error happens when the total time to read the response cross a pre-defined threshold.
Enumerate all possible errors that can happen and handle them.
1x - Bad input
2x - DNS errors
3x - Connection errors
4x - timeouts
5x - resource limits
Notes
Error 21
assocket.gethostbyname
does't respect timeoutsError 51
is different from timeout. It can happen that the server is giving data at very slow pace (one byte per second) without timing out. This error happens when the total time to read the response cross a pre-defined threshold.Can you think of any other possible errors?