1 2 package ch.ethz.ssh2; 3 4 import java.io.IOException ; 5 6 import ch.ethz.ssh2.sftp.ErrorCodes; 7 8 15 16 public class SFTPException extends IOException 17 { 18 private static final long serialVersionUID = 578654644222421811L; 19 20 private final String sftpErrorMessage; 21 private final int sftpErrorCode; 22 23 private static String constructMessage(String s, int errorCode) 24 { 25 String [] detail = ErrorCodes.getDescription(errorCode); 26 27 if (detail == null) 28 return s + " (UNKNOW SFTP ERROR CODE)"; 29 30 return s + " (" + detail[0] + ": " + detail[1] + ")"; 31 } 32 33 SFTPException(String msg, int errorCode) 34 { 35 super(constructMessage(msg, errorCode)); 36 sftpErrorMessage = msg; 37 sftpErrorCode = errorCode; 38 } 39 40 46 public String getServerErrorMessage() 47 { 48 return sftpErrorMessage; 49 } 50 51 56 public int getServerErrorCode() 57 { 58 return sftpErrorCode; 59 } 60 61 66 public String getServerErrorCodeSymbol() 67 { 68 String [] detail = ErrorCodes.getDescription(sftpErrorCode); 69 70 if (detail == null) 71 return "UNKNOW SFTP ERROR CODE " + sftpErrorCode; 72 73 return detail[0]; 74 } 75 76 81 public String getServerErrorCodeVerbose() 82 { 83 String [] detail = ErrorCodes.getDescription(sftpErrorCode); 84 85 if (detail == null) 86 return "The error code " + sftpErrorCode + " is unknown."; 87 88 return detail[1]; 89 } 90 } 91 | Popular Tags |