Check for connection error in main.

Hey, I put in a simple check for connection errors. If there is a connection issue I just log the error and return, otherwise request.statusCode breaks. Best solution it probably isn't but I do hope it is an improvement.