Smart way to use file_get_contents for web pages (timeout question)?

I'm using file_get_contents to get some Web page HTML and I realized there's got to be a smart approach for how to manage this in case of timeout or bad page. So far, though, all I can tell is file_get_contents just gives a PHP error if something goes wrong.

Is there a good/recommended way to retrieve a web page html from a URL and take into account managing bad pages and timeouts?