| 
									
										
										
										
											2018-01-27 09:26:44 +08:00
										 |  |  | package sftp | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-08-30 23:04:37 +08:00
										 |  |  | type fxerr uint32 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-01-27 09:26:44 +08:00
										 |  |  | // Error types that match the SFTP's SSH_FXP_STATUS codes. Gives you more
 | 
					
						
							|  |  |  | // direct control of the errors being sent vs. letting the library work them
 | 
					
						
							|  |  |  | // out from the standard os/io errors.
 | 
					
						
							| 
									
										
										
										
											2019-08-30 23:04:37 +08:00
										 |  |  | const ( | 
					
						
							|  |  |  | 	ErrSSHFxOk               = fxerr(sshFxOk) | 
					
						
							|  |  |  | 	ErrSSHFxEOF              = fxerr(sshFxEOF) | 
					
						
							|  |  |  | 	ErrSSHFxNoSuchFile       = fxerr(sshFxNoSuchFile) | 
					
						
							|  |  |  | 	ErrSSHFxPermissionDenied = fxerr(sshFxPermissionDenied) | 
					
						
							|  |  |  | 	ErrSSHFxFailure          = fxerr(sshFxFailure) | 
					
						
							|  |  |  | 	ErrSSHFxBadMessage       = fxerr(sshFxBadMessage) | 
					
						
							|  |  |  | 	ErrSSHFxNoConnection     = fxerr(sshFxNoConnection) | 
					
						
							|  |  |  | 	ErrSSHFxConnectionLost   = fxerr(sshFxConnectionLost) | 
					
						
							|  |  |  | 	ErrSSHFxOpUnsupported    = fxerr(sshFxOPUnsupported) | 
					
						
							|  |  |  | ) | 
					
						
							| 
									
										
										
										
											2018-01-27 09:26:44 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-08-30 23:04:37 +08:00
										 |  |  | // Deprecated error types, these are aliases for the new ones, please use the new ones directly
 | 
					
						
							| 
									
										
										
										
											2018-01-27 09:26:44 +08:00
										 |  |  | const ( | 
					
						
							| 
									
										
										
										
											2019-08-30 23:04:37 +08:00
										 |  |  | 	ErrSshFxOk               = ErrSSHFxOk | 
					
						
							|  |  |  | 	ErrSshFxEof              = ErrSSHFxEOF | 
					
						
							|  |  |  | 	ErrSshFxNoSuchFile       = ErrSSHFxNoSuchFile | 
					
						
							|  |  |  | 	ErrSshFxPermissionDenied = ErrSSHFxPermissionDenied | 
					
						
							|  |  |  | 	ErrSshFxFailure          = ErrSSHFxFailure | 
					
						
							|  |  |  | 	ErrSshFxBadMessage       = ErrSSHFxBadMessage | 
					
						
							|  |  |  | 	ErrSshFxNoConnection     = ErrSSHFxNoConnection | 
					
						
							|  |  |  | 	ErrSshFxConnectionLost   = ErrSSHFxConnectionLost | 
					
						
							|  |  |  | 	ErrSshFxOpUnsupported    = ErrSSHFxOpUnsupported | 
					
						
							| 
									
										
										
										
											2018-01-27 09:26:44 +08:00
										 |  |  | ) | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | func (e fxerr) Error() string { | 
					
						
							|  |  |  | 	switch e { | 
					
						
							| 
									
										
										
										
											2019-08-30 23:04:37 +08:00
										 |  |  | 	case ErrSSHFxOk: | 
					
						
							| 
									
										
										
										
											2018-01-27 09:26:44 +08:00
										 |  |  | 		return "OK" | 
					
						
							| 
									
										
										
										
											2019-08-30 23:04:37 +08:00
										 |  |  | 	case ErrSSHFxEOF: | 
					
						
							| 
									
										
										
										
											2018-01-27 09:26:44 +08:00
										 |  |  | 		return "EOF" | 
					
						
							| 
									
										
										
										
											2019-08-30 23:04:37 +08:00
										 |  |  | 	case ErrSSHFxNoSuchFile: | 
					
						
							| 
									
										
										
										
											2021-03-20 18:47:11 +08:00
										 |  |  | 		return "no such file" | 
					
						
							| 
									
										
										
										
											2019-08-30 23:04:37 +08:00
										 |  |  | 	case ErrSSHFxPermissionDenied: | 
					
						
							| 
									
										
										
										
											2021-03-20 18:47:11 +08:00
										 |  |  | 		return "permission denied" | 
					
						
							| 
									
										
										
										
											2019-08-30 23:04:37 +08:00
										 |  |  | 	case ErrSSHFxBadMessage: | 
					
						
							| 
									
										
										
										
											2021-03-20 18:47:11 +08:00
										 |  |  | 		return "bad message" | 
					
						
							| 
									
										
										
										
											2019-08-30 23:04:37 +08:00
										 |  |  | 	case ErrSSHFxNoConnection: | 
					
						
							| 
									
										
										
										
											2021-03-20 18:47:11 +08:00
										 |  |  | 		return "no connection" | 
					
						
							| 
									
										
										
										
											2019-08-30 23:04:37 +08:00
										 |  |  | 	case ErrSSHFxConnectionLost: | 
					
						
							| 
									
										
										
										
											2021-03-20 18:47:11 +08:00
										 |  |  | 		return "connection lost" | 
					
						
							| 
									
										
										
										
											2019-08-30 23:04:37 +08:00
										 |  |  | 	case ErrSSHFxOpUnsupported: | 
					
						
							| 
									
										
										
										
											2021-03-20 18:47:11 +08:00
										 |  |  | 		return "operation unsupported" | 
					
						
							| 
									
										
										
										
											2018-01-27 09:26:44 +08:00
										 |  |  | 	default: | 
					
						
							| 
									
										
										
										
											2021-03-20 18:47:11 +08:00
										 |  |  | 		return "failure" | 
					
						
							| 
									
										
										
										
											2018-01-27 09:26:44 +08:00
										 |  |  | 	} | 
					
						
							|  |  |  | } |