comparison src/ch/ethz/ssh2/SFTPException.java @ 307:071eccdff8ea ganymed

fix java formatting
author Carl Byington <carl@five-ten-sg.com>
date Wed, 30 Jul 2014 14:16:58 -0700
parents 91a31873c42a
children
comparison
equal deleted inserted replaced
305:d2b303406d63 307:071eccdff8ea
9 import ch.ethz.ssh2.sftp.ErrorCodes; 9 import ch.ethz.ssh2.sftp.ErrorCodes;
10 10
11 /** 11 /**
12 * Used in combination with the SFTPv3Client. This exception wraps 12 * Used in combination with the SFTPv3Client. This exception wraps
13 * error messages sent by the SFTP server. 13 * error messages sent by the SFTP server.
14 * 14 *
15 * @author Christian Plattner 15 * @author Christian Plattner
16 * @version 2.50, 03/15/10 16 * @version 2.50, 03/15/10
17 */ 17 */
18 18
19 public class SFTPException extends IOException 19 public class SFTPException extends IOException {
20 { 20 private static final long serialVersionUID = 578654644222421811L;
21 private static final long serialVersionUID = 578654644222421811L;
22 21
23 private final String sftpErrorMessage; 22 private final String sftpErrorMessage;
24 private final int sftpErrorCode; 23 private final int sftpErrorCode;
25 24
26 private static String constructMessage(String s, int errorCode) 25 private static String constructMessage(String s, int errorCode) {
27 { 26 String[] detail = ErrorCodes.getDescription(errorCode);
28 String[] detail = ErrorCodes.getDescription(errorCode);
29 27
30 if (detail == null) 28 if (detail == null)
31 return s + " (UNKNOWN SFTP ERROR CODE)"; 29 return s + " (UNKNOWN SFTP ERROR CODE)";
32 30
33 return s + " (" + detail[0] + ": " + detail[1] + ")"; 31 return s + " (" + detail[0] + ": " + detail[1] + ")";
34 } 32 }
35 33
36 SFTPException(String msg, int errorCode) 34 SFTPException(String msg, int errorCode) {
37 { 35 super(constructMessage(msg, errorCode));
38 super(constructMessage(msg, errorCode)); 36 sftpErrorMessage = msg;
39 sftpErrorMessage = msg; 37 sftpErrorCode = errorCode;
40 sftpErrorCode = errorCode; 38 }
41 }
42 39
43 /** 40 /**
44 * Get the error message sent by the server. Often, this 41 * Get the error message sent by the server. Often, this
45 * message does not help a lot (e.g., "failure"). 42 * message does not help a lot (e.g., "failure").
46 * 43 *
47 * @return the plain string as sent by the server. 44 * @return the plain string as sent by the server.
48 */ 45 */
49 public String getServerErrorMessage() 46 public String getServerErrorMessage() {
50 { 47 return sftpErrorMessage;
51 return sftpErrorMessage; 48 }
52 }
53 49
54 /** 50 /**
55 * Get the error code sent by the server. 51 * Get the error code sent by the server.
56 * 52 *
57 * @return an error code as defined in the SFTP specs. 53 * @return an error code as defined in the SFTP specs.
58 */ 54 */
59 public int getServerErrorCode() 55 public int getServerErrorCode() {
60 { 56 return sftpErrorCode;
61 return sftpErrorCode; 57 }
62 }
63 58
64 /** 59 /**
65 * Get the symbolic name of the error code as given in the SFTP specs. 60 * Get the symbolic name of the error code as given in the SFTP specs.
66 * 61 *
67 * @return e.g., "SSH_FX_INVALID_FILENAME". 62 * @return e.g., "SSH_FX_INVALID_FILENAME".
68 */ 63 */
69 public String getServerErrorCodeSymbol() 64 public String getServerErrorCodeSymbol() {
70 { 65 String[] detail = ErrorCodes.getDescription(sftpErrorCode);
71 String[] detail = ErrorCodes.getDescription(sftpErrorCode);
72 66
73 if (detail == null) 67 if (detail == null)
74 return "UNKNOWN SFTP ERROR CODE " + sftpErrorCode; 68 return "UNKNOWN SFTP ERROR CODE " + sftpErrorCode;
75 69
76 return detail[0]; 70 return detail[0];
77 } 71 }
78 72
79 /** 73 /**
80 * Get the description of the error code as given in the SFTP specs. 74 * Get the description of the error code as given in the SFTP specs.
81 * 75 *
82 * @return e.g., "The filename is not valid." 76 * @return e.g., "The filename is not valid."
83 */ 77 */
84 public String getServerErrorCodeVerbose() 78 public String getServerErrorCodeVerbose() {
85 { 79 String[] detail = ErrorCodes.getDescription(sftpErrorCode);
86 String[] detail = ErrorCodes.getDescription(sftpErrorCode);
87 80
88 if (detail == null) 81 if (detail == null)
89 return "The error code " + sftpErrorCode + " is unknown."; 82 return "The error code " + sftpErrorCode + " is unknown.";
90 83
91 return detail[1]; 84 return detail[1];
92 } 85 }
93 } 86 }