@@ -21,10 +21,10 @@ from sftp_handles cimport SFTPFile, SFTPDir
2121from sftp_attributes cimport SFTPAttributes
2222from sftp_statvfs cimport SFTPStatVFS
2323from utils cimport handle_ssh_error_codes, to_bytes
24- from .exceptions import SFTPHandleError
24+ from .exceptions import SFTPError
2525
2626cimport c_sftp
27- from c_ssh cimport ssh_get_error_code, timeval
27+ from c_ssh cimport ssh_get_error, ssh_get_error_code, timeval
2828
2929
3030cdef class SFTP:
@@ -98,12 +98,7 @@ cdef class SFTP:
9898 with nogil:
9999 c_dir = c_sftp.sftp_opendir(self ._sftp, c_path)
100100 if c_dir is NULL :
101- # May or may not be an 'ssh error' which only handles
102- # three error types
103- handle_ssh_error_codes(
104- ssh_get_error_code(self .session._session),
105- self .session._session)
106- raise SFTPHandleError
101+ raise SFTPError(ssh_get_error(self .session._session))
107102 _dir = SFTPDir.from_ptr(c_dir, self )
108103 return _dir
109104
@@ -115,10 +110,7 @@ cdef class SFTP:
115110 with nogil:
116111 c_attrs = c_sftp.sftp_stat(self ._sftp, c_path)
117112 if c_attrs is NULL :
118- handle_ssh_error_codes(
119- ssh_get_error_code(self .session._session),
120- self .session._session)
121- raise SFTPHandleError
113+ raise SFTPError(ssh_get_error(self .session._session))
122114 _attrs = SFTPAttributes.from_ptr(c_attrs, self )
123115 return _attrs
124116
@@ -130,10 +122,7 @@ cdef class SFTP:
130122 with nogil:
131123 c_attrs = c_sftp.sftp_lstat(self ._sftp, c_path)
132124 if c_attrs is NULL :
133- handle_ssh_error_codes(
134- ssh_get_error_code(self .session._session),
135- self .session._session)
136- raise SFTPHandleError
125+ raise SFTPError(ssh_get_error(self .session._session))
137126 _attrs = SFTPAttributes.from_ptr(c_attrs, self )
138127 return _attrs
139128
@@ -145,10 +134,7 @@ cdef class SFTP:
145134 with nogil:
146135 c_file = c_sftp.sftp_open(self ._sftp, c_path, accesstype, mode)
147136 if c_file is NULL :
148- handle_ssh_error_codes(
149- ssh_get_error_code(self .session._session),
150- self .session._session)
151- raise SFTPHandleError
137+ raise SFTPError(ssh_get_error(self .session._session))
152138 _file = SFTPFile.from_ptr(c_file, self )
153139 return _file
154140
@@ -158,7 +144,7 @@ cdef class SFTP:
158144 cdef int rc
159145 with nogil:
160146 rc = c_sftp.sftp_unlink(self ._sftp, c_path)
161- return handle_ssh_error_codes(rc, self .session._session)
147+ return handle_ssh_error_codes(rc, self .session._session)
162148
163149 def rmdir (self , path not None ):
164150 cdef bytes b_path = to_bytes(path)
0 commit comments