Skip to content

Commit 2167409

Browse files
author
Gauvain Pocentek
committed
Make todo() raise GitlabTodoError on error
1 parent b775069 commit 2167409

File tree

2 files changed

+8
-2
lines changed

2 files changed

+8
-2
lines changed

RELEASE_NOTES.rst

+1
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ Changes from 1.1 to 1.2
1616
``set_token`` and ``set_credentials`` methods. Once a Gitlab object has been
1717
created its URL and authentication information cannot be updated: create a
1818
new Gitlab object if you need to use new information
19+
* The ``todo()`` method raises a ``GitlabTodoError`` exception on error
1920

2021
Changes from 1.0.2 to 1.1
2122
=========================

gitlab/mixins.py

+7-2
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,12 @@ def get(self, id, **kwargs):
113113
GitlabAuthenticationError: If authentication is not correct
114114
GitlabGetError: If the server cannot perform the request
115115
"""
116-
gen = self.list()
116+
try:
117+
gen = self.list()
118+
except exc.GitlabListError:
119+
raise exc.GitlabGetError(response_code=404,
120+
error_message="Not found")
121+
117122
for obj in gen:
118123
if str(obj.get_id()) == str(id):
119124
return obj
@@ -382,7 +387,7 @@ def unsubscribe(self, **kwargs):
382387

383388
class TodoMixin(object):
384389
@cli.register_custom_action(('ProjectIssue', 'ProjectMergeRequest'))
385-
@exc.on_http_error(exc.GitlabHttpError)
390+
@exc.on_http_error(exc.GitlabTodoError)
386391
def todo(self, **kwargs):
387392
"""Create a todo associated to the object.
388393

0 commit comments

Comments
 (0)