At the server side, you can register FileUploaded event handler. The event arguments contain HasFailed property, which can be used to determine whether the handle of the uploaded file was properly closed. If it was not, it indicates that the SFTP session most failed. However, please be aware that if the upload was canceled by the client side before the file was fully uploaded, and the handle has been closed, then it won't be possible to detect this as failed upload at the server. This is a limitation of the SFTP protocol.
At the client side (when using
Rebex.Net.Sftp class), you can detect SFTP error codes and messages by catching and handling SftpException with relevant status code. See the linked post for details.
Update: Fixed the answer to address the server side as well.