{"action":"closed","issue":{"url":"https://api.github.com/repos/cloudant/python-cloudant/issues/247","repository_url":"https://api.github.com/repos/cloudant/python-cloudant","labels_url":"https://api.github.com/repos/cloudant/python-cloudant/issues/247/labels{/name}","comments_url":"https://api.github.com/repos/cloudant/python-cloudant/issues/247/comments","events_url":"https://api.github.com/repos/cloudant/python-cloudant/issues/247/events","html_url":"https://github.com/cloudant/python-cloudant/issues/247","id":189769516,"number":247,"title":"fetch() throws HTTPError if design doc doesn't exist","user":{"login":"snowch","id":147713,"avatar_url":"https://avatars.githubusercontent.com/u/147713?v=3","gravatar_id":"","url":"https://api.github.com/users/snowch","html_url":"https://github.com/snowch","followers_url":"https://api.github.com/users/snowch/followers","following_url":"https://api.github.com/users/snowch/following{/other_user}","gists_url":"https://api.github.com/users/snowch/gists{/gist_id}","starred_url":"https://api.github.com/users/snowch/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/snowch/subscriptions","organizations_url":"https://api.github.com/users/snowch/orgs","repos_url":"https://api.github.com/users/snowch/repos","events_url":"https://api.github.com/users/snowch/events{/privacy}","received_events_url":"https://api.github.com/users/snowch/received_events","type":"User","site_admin":false},"labels":[],"state":"closed","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":4,"created_at":"2016-11-16T16:54:53Z","updated_at":"2016-11-29T10:45:09Z","closed_at":"2016-11-29T10:45:09Z","body":"- Cloudant (python-cloudant) version(s) that are affected by this issue: 2.3.0\r\n- Python version: n/a\r\n- A small code sample that demonstrates the issue.\r\n\r\nI would like to check if a design doc already exists before I attempt to create it.  From the [documentation][1] it appears I need to call fetch to load docs, but that returns a HTTPError:\r\n\r\n```\r\n    ratingdb = cloudant_client[CL_RATINGDB]\r\n    ddoc = DesignDocument(ratingdb, CL_RATINGDB_RATING_IDX)\r\n\r\n    try:\r\n        ddoc.fetch()\r\n\r\n    except HTTPError:\r\n        print('httperror fetching {0} design doc', CL_RATINGDB_RATING_IDX)\r\n\r\n        ddoc.add_search_index(\r\n                CL_RATINGDB_RATING_IDX, \r\n                'TODO my function', \r\n                analyzer=None)\r\n        ddoc.save()\r\n```\r\nShould fetch() return None rather than a 404 error if the design doc doesn't exist on the server?\r\n\r\n\r\n  [1]: http://python-cloudant.readthedocs.io/en/latest/design_document.html"}}
{"actor":{"display_login":"snowch"}}