What is the best way to handle errors in plugins and templates?
Yep, Craft makes pretty liberal use of try/catch blocks. Wrap your HTTP request in that, and return whatever makes sense in the context – null, false, or maybe an empty array.

Probably also worth logging the error, so the developer can investigate why it’s not working, using Craft::log().

Remember when catching exceptions, that there’s a good chance the exception class won’t be in Craft’s namespace. So you’ll probably need to prepend the exception class(es) with \.

So to put it all together:

try
{
    // Make the HTTP request
    // ...
}
catch (\Exception $e)
{
    Craft::log('The request to domain.com failed: '.$e-&gt;getMessage(),
               LogLevel::Warning, false, 'mypluginhandle');

    return false;
}