Skip to content

Commit eeba9c1

Browse files
author
Pan
committed
Error code to exceptions handling
1 parent 24ddbf3 commit eeba9c1

File tree

7 files changed

+5163
-1555
lines changed

7 files changed

+5163
-1555
lines changed

ssh2/exceptions.c

Lines changed: 1586 additions & 194 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

ssh2/exceptions.pyx

Lines changed: 193 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# This file is part of ssh2-python.
2-
# Copyright (C) 2017 Panos Kittenis
2+
# Copyright (C) 2017-2018 Panos Kittenis
33

44
# This library is free software; you can redistribute it and/or
55
# modify it under the terms of the GNU Lesser General Public
@@ -16,59 +16,231 @@
1616

1717

1818
class AgentError(Exception):
19-
pass
19+
"""Base class for all SSH Agent errors"""
2020

2121

2222
class AuthenticationError(Exception):
23-
pass
23+
"""Base class for all authentication errors"""
2424

2525

2626
class AgentConnectionError(AgentError):
27-
pass
27+
"""Raised on SSH Agent connection errors"""
2828

2929

3030
class AgentAuthenticationError(AuthenticationError):
31-
pass
31+
"""Raised on SSH Agent authentication errors"""
3232

3333

3434
class AgentListIdentitiesError(AgentError):
35-
pass
35+
"""Raised on SSH Agent list identities errors"""
3636

3737

3838
class AgentGetIdentityError(AgentError):
39-
pass
39+
"""Raised on SSH Agent get identity errors"""
4040

4141

42-
class SessionStartupError(Exception):
43-
pass
42+
class AgentProtocolError(Exception):
43+
"""Raised on SSH agent protocol errors"""
4444

4545

46-
class SessionHandshakeError(Exception):
47-
pass
46+
class SessionError(Exception):
47+
"""Base class for all session errors"""
4848

4949

50-
class SessionHostKeyError(Exception):
50+
class SessionStartupError(SessionError):
51+
"""Raised on session startup errors"""
52+
53+
54+
class SessionHandshakeError(SessionError):
55+
"""Raised on session handshake errors"""
56+
57+
58+
class SessionHostKeyError(SessionError):
5159
"""Raised on errors getting server host key"""
5260

5361

54-
class SCPError(Exception):
55-
"""Raised on SCP errors"""
62+
class BannerRecvError(SessionError):
63+
"""Raised on errors receiving banner"""
64+
65+
66+
class BannerSendError(SessionError):
67+
"""Raised on errors sending banner"""
68+
69+
70+
class KeyExchangeError(SessionError):
71+
"""Raised on errors exchanging keys"""
72+
73+
74+
class Timeout(SessionError):
75+
"""Raised on timeouts"""
76+
77+
78+
class HostkeyInitError(SessionError):
79+
"""Raised on errors initialiasing host key"""
80+
81+
82+
class HostkeySignError(SessionError):
83+
"""Raised on errors signing host key"""
84+
85+
86+
class DecryptError(SessionError):
87+
"""Raised on decryption errors"""
88+
89+
90+
class SocketDisconnectError(Exception):
91+
"""Raised on socket disconnection errors"""
92+
93+
94+
class ProtocolError(Exception):
95+
"""Raised on protocol errors"""
96+
97+
98+
class PasswordExpiredError(AuthenticationError):
99+
"""Raised on password expired errors"""
100+
101+
102+
class FileError(Exception):
103+
"""Raised on file errors"""
104+
105+
106+
class MethodNoneError(Exception):
107+
"""Raised on invalid method errors"""
108+
109+
110+
class PublicKeyError(Exception):
111+
"""Base class for all public key protocol errors"""
112+
113+
114+
class PublicKeyInitError(PublicKeyError):
115+
"""Raised on errors initialising public key system"""
116+
117+
118+
class PublickeyUnrecognizedError(SessionError):
119+
"""Raised on unrecognised public key errors"""
120+
121+
122+
class PublickeyUnverifiedError(SessionError):
123+
"""Raised on public key verification errors"""
56124

57125

58126
class ChannelError(Exception):
59-
pass
127+
"""Base class for all channel errors"""
128+
129+
130+
class ChannelOutOfOrderError(ChannelError):
131+
"""Raised on channel commands out of order errors"""
132+
133+
134+
class ChannelFailure(ChannelError):
135+
"""Raised on channel failures"""
136+
137+
138+
class ChannelRequestDenied(ChannelError):
139+
"""Raised on channel request denied errors"""
140+
141+
142+
class ChannelUnknownError(ChannelError):
143+
"""Raised on unknown channel errors"""
144+
145+
146+
class ChannelWindowExceeded(ChannelError):
147+
"""Raised on channel window exceeded errors"""
148+
149+
150+
class ChannelPacketExceeded(ChannelError):
151+
"""Raised on channel max packet length exceeded errors"""
152+
153+
154+
class ChannelClosedError(ChannelError):
155+
"""Raised on channel closed errors"""
156+
157+
158+
class ChannelEOFSentError(ChannelError):
159+
"""Raised on channel EOF errors"""
160+
161+
162+
class SCPError(Exception):
163+
"""Raised on SCP errors. Base class for all SCP exceptions."""
164+
165+
166+
class SCPProtocolError(SCPError):
167+
"""Raised on SCP protocol errors"""
168+
169+
170+
class ZlibError(SessionError):
171+
"""Raised on zlib errors"""
172+
173+
174+
class SocketTimeout(SessionError):
175+
"""Raised on socket timeouts"""
176+
177+
178+
class RequestDeniedError(SessionError):
179+
"""Raised on request denied errors"""
180+
181+
182+
class MethodNotSupported(SessionError):
183+
"""Raised on authentication method not supported errors"""
184+
185+
186+
class InvalidError(Exception):
187+
"""Raised on invalid request errors"""
188+
189+
190+
class InvalidPollTypeError(Exception):
191+
"""Raised on invalid poll type errors"""
192+
193+
194+
class PublicKeyProtocolError(Exception):
195+
"""Raised on public key protocol errors"""
196+
197+
198+
class BufferTooSmallError(Exception):
199+
"""Raised on buffer too small errors"""
200+
201+
202+
class BadUseError(Exception):
203+
"""Raised on API bad use errors"""
204+
205+
206+
class CompressError(SessionError):
207+
"""Raised on compression errors"""
208+
209+
210+
class OutOfBoundaryError(Exception):
211+
"""Raised on out of boundary errors"""
212+
213+
214+
class SocketRecvError(Exception):
215+
"""Raised on socket receive errors"""
216+
217+
218+
class EncryptError(SessionError):
219+
"""Raised on encryption errors"""
220+
221+
222+
class BadSocketError(Exception):
223+
"""Raised on use of bad socket errors"""
224+
225+
226+
class SFTPError(Exception):
227+
"""Base class for SFTP errors"""
228+
229+
230+
class SFTPProtocolError(SFTPError):
231+
"""Raised on SFTP protocol errors"""
60232

61233

62-
class SFTPHandleError(Exception):
63-
pass
234+
class SFTPHandleError(SFTPError):
235+
"""Raised on SFTP handle errors"""
64236

65237

66-
class SFTPBufferTooSmall(Exception):
67-
pass
238+
class SFTPBufferTooSmall(SFTPError):
239+
"""Raised on SFTP buffer too small errors"""
68240

69241

70-
class SFTPIOError(Exception):
71-
pass
242+
class SFTPIOError(SFTPError):
243+
"""Raised on SFTP I/O errors"""
72244

73245

74246
class KnownHostError(Exception):

0 commit comments

Comments
 (0)