Throw error message if connection is not successful