Skip to content

Commit 08d3ccf

Browse files
author
Gauvain Pocentek
committed
make connection exceptions more explicit
1 parent 2eac071 commit 08d3ccf

File tree

1 file changed

+18
-18
lines changed

1 file changed

+18
-18
lines changed

gitlab/__init__.py

+18-18
Original file line numberDiff line numberDiff line change
@@ -264,9 +264,9 @@ def _raw_get(self, path, content_type=None, **kwargs):
264264
headers=headers,
265265
verify=self.ssl_verify,
266266
timeout=self.timeout)
267-
except Exception:
267+
except Exception as e:
268268
raise GitlabConnectionError(
269-
"Can't connect to GitLab server (%s)" % self._url)
269+
"Can't connect to GitLab server (%s)" % e)
270270

271271
def _raw_post(self, path, data=None, content_type=None, **kwargs):
272272
url = '%s%s' % (self._url, path)
@@ -276,9 +276,9 @@ def _raw_post(self, path, data=None, content_type=None, **kwargs):
276276
headers=headers,
277277
verify=self.ssl_verify,
278278
timeout=self.timeout)
279-
except Exception:
279+
except Exception as e:
280280
raise GitlabConnectionError(
281-
"Can't connect to GitLab server (%s)" % self._url)
281+
"Can't connect to GitLab server (%s)" % e)
282282

283283
def _raw_put(self, path, data=None, content_type=None, **kwargs):
284284
url = '%s%s' % (self._url, path)
@@ -289,9 +289,9 @@ def _raw_put(self, path, data=None, content_type=None, **kwargs):
289289
headers=headers,
290290
verify=self.ssl_verify,
291291
timeout=self.timeout)
292-
except Exception:
292+
except Exception as e:
293293
raise GitlabConnectionError(
294-
"Can't connect to GitLab server (%s)" % self._url)
294+
"Can't connect to GitLab server (%s)" % e)
295295

296296
def _raw_delete(self, path, content_type=None, **kwargs):
297297
url = '%s%s' % (self._url, path)
@@ -303,9 +303,9 @@ def _raw_delete(self, path, content_type=None, **kwargs):
303303
headers=headers,
304304
verify=self.ssl_verify,
305305
timeout=self.timeout)
306-
except Exception:
306+
except Exception as e:
307307
raise GitlabConnectionError(
308-
"Can't connect to GitLab server (%s)" % self._url)
308+
"Can't connect to GitLab server (%s)" % e)
309309

310310
def list(self, obj_class, **kwargs):
311311
"""Request the listing of GitLab resources.
@@ -343,9 +343,9 @@ def list(self, obj_class, **kwargs):
343343
r = requests.get(url, params=params, headers=headers,
344344
verify=self.ssl_verify,
345345
timeout=self.timeout)
346-
except Exception:
346+
except Exception as e:
347347
raise GitlabConnectionError(
348-
"Can't connect to GitLab server (%s)" % self._url)
348+
"Can't connect to GitLab server (%s)" % e)
349349

350350
raise_error_from_response(r, GitlabListError)
351351

@@ -413,9 +413,9 @@ def get(self, obj_class, id=None, **kwargs):
413413
try:
414414
r = requests.get(url, params=params, headers=headers,
415415
verify=self.ssl_verify, timeout=self.timeout)
416-
except Exception:
416+
except Exception as e:
417417
raise GitlabConnectionError(
418-
"Can't connect to GitLab server (%s)" % self._url)
418+
"Can't connect to GitLab server (%s)" % e)
419419

420420
raise_error_from_response(r, GitlabGetError)
421421
return r.json()
@@ -469,9 +469,9 @@ def delete(self, obj, id=None, **kwargs):
469469
headers=headers,
470470
verify=self.ssl_verify,
471471
timeout=self.timeout)
472-
except Exception:
472+
except Exception as e:
473473
raise GitlabConnectionError(
474-
"Can't connect to GitLab server (%s)" % self._url)
474+
"Can't connect to GitLab server (%s)" % e)
475475

476476
raise_error_from_response(r, GitlabDeleteError)
477477
return True
@@ -516,9 +516,9 @@ def create(self, obj, **kwargs):
516516
headers=headers,
517517
verify=self.ssl_verify,
518518
timeout=self.timeout)
519-
except Exception:
519+
except Exception as e:
520520
raise GitlabConnectionError(
521-
"Can't connect to GitLab server (%s)" % self._url)
521+
"Can't connect to GitLab server (%s)" % e)
522522

523523
raise_error_from_response(r, GitlabCreateError, 201)
524524
return r.json()
@@ -562,9 +562,9 @@ def update(self, obj, **kwargs):
562562
headers=headers,
563563
verify=self.ssl_verify,
564564
timeout=self.timeout)
565-
except Exception:
565+
except Exception as e:
566566
raise GitlabConnectionError(
567-
"Can't connect to GitLab server (%s)" % self._url)
567+
"Can't connect to GitLab server (%s)" % e)
568568

569569
raise_error_from_response(r, GitlabUpdateError)
570570
return r.json()

0 commit comments

Comments
 (0)