Added basic error handling on the url connection.