1
Vote

There is no indication from TeamCityClient.ctor() that the connection failed.

description

Repro steps:
Expected:
  • An exception is thrown, or an invalid TeamCityClient object is returned.
Actual:
  • No exception is thrown, and a TeamCityClient object is returned. It's not until you start peeking into the TeamCityClient instance (e.g., by getting teamCity.ServerInfo) that you realise the connection failed. Currently I have this rather ugly block of code to handle this possibility:
        client = new TeamCityClient(teamCityServerUrl, username, password);
    
        try
        {
            // Check to see if the connection was correctly established.  Currently
            // no better way to do this with Sharp2City.
            var serverInfo = client.ServerInfo;
        }
        catch (WebException ex)
        {
            // handle exceptions like timeout, could not resolve address, etc.
        }
        catch (UriFormatException ex)
        {
            // handle invalid URL exceptions.
        }

comments