comparison venv/lib/python2.7/site-packages/github/GithubException.py @ 0:d67268158946 draft

planemo upload commit a3f181f5f126803c654b3a66dd4e83a48f7e203b
author bcclaywell
date Mon, 12 Oct 2015 17:43:33 -0400
parents
children
comparison
equal deleted inserted replaced
-1:000000000000 0:d67268158946
1 # -*- coding: utf-8 -*-
2
3 # ########################## Copyrights and license ############################
4 # #
5 # Copyright 2012 Vincent Jacques <vincent@vincent-jacques.net> #
6 # Copyright 2012 Zearin <zearin@gonk.net> #
7 # Copyright 2013 AKFish <akfish@gmail.com> #
8 # Copyright 2013 Vincent Jacques <vincent@vincent-jacques.net> #
9 # #
10 # This file is part of PyGithub. http://jacquev6.github.com/PyGithub/ #
11 # #
12 # PyGithub is free software: you can redistribute it and/or modify it under #
13 # the terms of the GNU Lesser General Public License as published by the Free #
14 # Software Foundation, either version 3 of the License, or (at your option) #
15 # any later version. #
16 # #
17 # PyGithub is distributed in the hope that it will be useful, but WITHOUT ANY #
18 # WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS #
19 # FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more #
20 # details. #
21 # #
22 # You should have received a copy of the GNU Lesser General Public License #
23 # along with PyGithub. If not, see <http://www.gnu.org/licenses/>. #
24 # #
25 # ##############################################################################
26
27
28 class GithubException(Exception):
29 """
30 Error handling in PyGithub is done with exceptions. This class is the base of all exceptions raised by PyGithub (but :class:`github.GithubException.BadAttributeException`).
31
32 Some other types of exceptions might be raised by underlying libraries, for example for network-related issues.
33 """
34
35 def __init__(self, status, data):
36 Exception.__init__(self)
37 self.__status = status
38 self.__data = data
39
40 @property
41 def status(self):
42 """
43 The status returned by the Github API
44 """
45 return self.__status
46
47 @property
48 def data(self):
49 """
50 The (decoded) data returned by the Github API
51 """
52 return self.__data
53
54 def __str__(self):
55 return str(self.status) + " " + str(self.data)
56
57
58 class BadCredentialsException(GithubException):
59 """
60 Exception raised in case of bad credentials (when Github API replies with a 401 or 403 HTML status)
61 """
62
63
64 class UnknownObjectException(GithubException):
65 """
66 Exception raised when a non-existing object is requested (when Github API replies with a 404 HTML status)
67 """
68
69
70 class BadUserAgentException(GithubException):
71 """
72 Exception raised when request is sent with a bad user agent header (when Github API replies with a 403 bad user agent HTML status)
73 """
74
75
76 class RateLimitExceededException(GithubException):
77 """
78 Exception raised when the rate limit is exceeded (when Github API replies with a 403 rate limit exceeded HTML status)
79 """
80
81
82 class BadAttributeException(Exception):
83 """
84 Exception raised when Github returns an attribute with the wrong type.
85 """
86 def __init__(self, actualValue, expectedType, transformationException):
87 self.__actualValue = actualValue
88 self.__expectedType = expectedType
89 self.__transformationException = transformationException
90
91 @property
92 def actual_value(self):
93 """
94 The value returned by Github
95 """
96 return self.__actualValue
97
98 @property
99 def expected_type(self):
100 """
101 The type PyGithub expected
102 """
103 return self.__expectedType
104
105 @property
106 def transformation_exception(self):
107 """
108 The exception raised when PyGithub tried to parse the value
109 """
110 return self.__transformationException
111
112
113 class TwoFactorException(GithubException):
114 """
115 Exception raised when Github requires a onetime password for two-factor authentication
116 """