def catch_request(request):
 try:
  uh = urlopen(request)
  return (uh, False)
 except HTTP_ERRORS:
  e = get_exception()
  return (None, e)

def catch_request ( request ) : try : uh = urlopen ( request ) return ( uh , False ) except HTTP_ERRORS : e = get_exception ( ) return ( None , e )
helper function to catch common exceptions encountered when establishing a connection with a http/https request .