GitHub Access Token became invalid

It seems like the GitHub access token used for retrieving details about this repository from GitHub became invalid. This might prevent certain types of inspections from being run (in particular, everything related to pull requests).
Please ask an admin of your repository to re-new the access token on this website.
Passed
Push — v1 ( b4dcfa...110339 )
by Maksim
01:36
created

Route4MeApiError.__init__()   A

Complexity

Conditions 1

Size

Total Lines 19

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 4
CRAP Score 1

Importance

Changes 0
Metric Value
cc 1
c 0
b 0
f 0
dl 0
loc 19
rs 9.4285
ccs 4
cts 4
cp 1
crap 1
1
# -*- coding: utf-8 -*-
2
3
4 1
class Route4MeError(Exception):
5
	"""
6
	Base (abstract) error-class
7
	"""
8 1
	def __init__(
9
		self,
10
		message,
11
		code='route4me.sdk.other',
12
		details=None,
13
		inner=None,
14
	):
15 1
		super(Route4MeError, self).__init__(message)
16
17
		#: Unique error code. Helps to distinguish different errors.
18
		#:
19
		#: :type: str
20 1
		self.code = code
21
22 1
		if details is not None:
23 1
			assert isinstance(details, dict)
24
25
		#: Some error details
26
		#:
27
		#: :type: dict
28 1
		self.details = details
29
30
		#: Internal exception that describes an original error.
31
		#:
32
		#: :type: Exception
33 1
		self.inner = inner
34
35 1
	def get_message(self):
36 1
		return super(Route4MeError, self).__str__()
37
38 1
	def __str__(self):
39
40 1
		s = '{tp}: [{code}] {message}'.format(
41
			tp=type(self).__name__,
42
			code=self.code,
43
			message=self.get_message(),
44
		)
45 1
		return s
46
47
48 1
class Route4MeNetworkError(Route4MeError):
49
	"""
50
	Route4Me SDK network/connection errors.
51
52
	Occurs on:
53
54
	- invalid SSL
55
	- network timeout
56
	- wrong redirects (Route4Me API doesn't send redirect responses)
57
	- no connection, no path to route (DNS)
58
59
	More details could be observed using :py:attr:`~.Route4MeError.code` and
60
	:py:attr:`~.Route4MeError.details`
61
	"""
62 1
	pass
63
64
65 1
class Route4MeApiError(Route4MeError):
66
	"""
67
	Error on Route4Me SDK
68
69
	.. todo::
70
		Make this exception more detailed
71
72
	"""
73 1
	def __init__(
74
		self,
75
		message,
76
		code='route4me.sdk.other',
77
		details=None,
78
		inner=None,
79
80
		method=None,
81
		url=None,
82
	):
83 1
		super(Route4MeApiError, self).__init__(
84
			message,
85
			code,
86
			details,
87
			inner
88
		)
89
90 1
		self.method = method
91 1
		self.url = url
92
93
94 1
class Route4MeValidationError(Route4MeError):
95
	"""
96
	Route4Me Validation error.
97
98
	Variable has invalid format/data
99
	"""
100 1
	pass
101
102
103 1
class Route4MeEntityNotFoundError(Route4MeError):
104
	"""
105
	Requested entity was not found on Route4Me
106
	"""
107
	pass
108