AppHarbor.Client.AppHarborClient.ServiceHookExists C# (CSharp) Method

ServiceHookExists() private method

private ServiceHookExists ( string token, string projectName, string serviceHookUrl ) : bool
token string
projectName string
serviceHookUrl string
return bool
        bool ServiceHookExists(string token, string projectName, string serviceHookUrl)
        {
            try
            {
                var url = string.Format(GetProject(token, projectName).ProjectUrl + "/servicehooks", projectName);
                var cli = GetAuthenticatedWebRequest(token, url);
                cli.Accept = "application/json";
                var sr = new StreamReader(cli.GetResponse().GetResponseStream());

                var resp = sr.ReadToEnd();

                dynamic obj = JsonConvert.DeserializeObject(resp);

                foreach (var o in obj)
                {
                    if (o.url == serviceHookUrl)
                        return true;
                }
            }
            catch (WebException we)
            {
                //TODO: What is the "right" way to do this?
                // We will swallow the 404 here because AppHarbor returns
                // a 404 in the case that I am a collaborator on a project
                // and not the owner, and I try to access the servicehook url
                if (!we.Message.Contains("404"))
                {
                    throw we;
                }
            }
            catch (Exception e)
            {
                throw e;
            }
            return false;
        }