Mercurial > 510Connectbot
annotate src/ch/ethz/ssh2/SFTPException.java @ 372:20d0a1356c43
debug kex error
author | Carl Byington <carl@five-ten-sg.com> |
---|---|
date | Mon, 04 Aug 2014 12:11:12 -0700 |
parents | 071eccdff8ea |
children |
rev | line source |
---|---|
273
91a31873c42a
start conversion from trilead to ganymed
Carl Byington <carl@five-ten-sg.com>
parents:
diff
changeset
|
1 /* |
91a31873c42a
start conversion from trilead to ganymed
Carl Byington <carl@five-ten-sg.com>
parents:
diff
changeset
|
2 * Copyright (c) 2006-2011 Christian Plattner. All rights reserved. |
91a31873c42a
start conversion from trilead to ganymed
Carl Byington <carl@five-ten-sg.com>
parents:
diff
changeset
|
3 * Please see the LICENSE.txt for licensing details. |
91a31873c42a
start conversion from trilead to ganymed
Carl Byington <carl@five-ten-sg.com>
parents:
diff
changeset
|
4 */ |
91a31873c42a
start conversion from trilead to ganymed
Carl Byington <carl@five-ten-sg.com>
parents:
diff
changeset
|
5 package ch.ethz.ssh2; |
91a31873c42a
start conversion from trilead to ganymed
Carl Byington <carl@five-ten-sg.com>
parents:
diff
changeset
|
6 |
91a31873c42a
start conversion from trilead to ganymed
Carl Byington <carl@five-ten-sg.com>
parents:
diff
changeset
|
7 import java.io.IOException; |
91a31873c42a
start conversion from trilead to ganymed
Carl Byington <carl@five-ten-sg.com>
parents:
diff
changeset
|
8 |
91a31873c42a
start conversion from trilead to ganymed
Carl Byington <carl@five-ten-sg.com>
parents:
diff
changeset
|
9 import ch.ethz.ssh2.sftp.ErrorCodes; |
91a31873c42a
start conversion from trilead to ganymed
Carl Byington <carl@five-ten-sg.com>
parents:
diff
changeset
|
10 |
91a31873c42a
start conversion from trilead to ganymed
Carl Byington <carl@five-ten-sg.com>
parents:
diff
changeset
|
11 /** |
91a31873c42a
start conversion from trilead to ganymed
Carl Byington <carl@five-ten-sg.com>
parents:
diff
changeset
|
12 * Used in combination with the SFTPv3Client. This exception wraps |
91a31873c42a
start conversion from trilead to ganymed
Carl Byington <carl@five-ten-sg.com>
parents:
diff
changeset
|
13 * error messages sent by the SFTP server. |
307 | 14 * |
273
91a31873c42a
start conversion from trilead to ganymed
Carl Byington <carl@five-ten-sg.com>
parents:
diff
changeset
|
15 * @author Christian Plattner |
91a31873c42a
start conversion from trilead to ganymed
Carl Byington <carl@five-ten-sg.com>
parents:
diff
changeset
|
16 * @version 2.50, 03/15/10 |
91a31873c42a
start conversion from trilead to ganymed
Carl Byington <carl@five-ten-sg.com>
parents:
diff
changeset
|
17 */ |
91a31873c42a
start conversion from trilead to ganymed
Carl Byington <carl@five-ten-sg.com>
parents:
diff
changeset
|
18 |
307 | 19 public class SFTPException extends IOException { |
20 private static final long serialVersionUID = 578654644222421811L; | |
273
91a31873c42a
start conversion from trilead to ganymed
Carl Byington <carl@five-ten-sg.com>
parents:
diff
changeset
|
21 |
307 | 22 private final String sftpErrorMessage; |
23 private final int sftpErrorCode; | |
273
91a31873c42a
start conversion from trilead to ganymed
Carl Byington <carl@five-ten-sg.com>
parents:
diff
changeset
|
24 |
307 | 25 private static String constructMessage(String s, int errorCode) { |
26 String[] detail = ErrorCodes.getDescription(errorCode); | |
273
91a31873c42a
start conversion from trilead to ganymed
Carl Byington <carl@five-ten-sg.com>
parents:
diff
changeset
|
27 |
307 | 28 if (detail == null) |
29 return s + " (UNKNOWN SFTP ERROR CODE)"; | |
273
91a31873c42a
start conversion from trilead to ganymed
Carl Byington <carl@five-ten-sg.com>
parents:
diff
changeset
|
30 |
307 | 31 return s + " (" + detail[0] + ": " + detail[1] + ")"; |
32 } | |
273
91a31873c42a
start conversion from trilead to ganymed
Carl Byington <carl@five-ten-sg.com>
parents:
diff
changeset
|
33 |
307 | 34 SFTPException(String msg, int errorCode) { |
35 super(constructMessage(msg, errorCode)); | |
36 sftpErrorMessage = msg; | |
37 sftpErrorCode = errorCode; | |
38 } | |
273
91a31873c42a
start conversion from trilead to ganymed
Carl Byington <carl@five-ten-sg.com>
parents:
diff
changeset
|
39 |
307 | 40 /** |
41 * Get the error message sent by the server. Often, this | |
42 * message does not help a lot (e.g., "failure"). | |
43 * | |
44 * @return the plain string as sent by the server. | |
45 */ | |
46 public String getServerErrorMessage() { | |
47 return sftpErrorMessage; | |
48 } | |
273
91a31873c42a
start conversion from trilead to ganymed
Carl Byington <carl@five-ten-sg.com>
parents:
diff
changeset
|
49 |
307 | 50 /** |
51 * Get the error code sent by the server. | |
52 * | |
53 * @return an error code as defined in the SFTP specs. | |
54 */ | |
55 public int getServerErrorCode() { | |
56 return sftpErrorCode; | |
57 } | |
273
91a31873c42a
start conversion from trilead to ganymed
Carl Byington <carl@five-ten-sg.com>
parents:
diff
changeset
|
58 |
307 | 59 /** |
60 * Get the symbolic name of the error code as given in the SFTP specs. | |
61 * | |
62 * @return e.g., "SSH_FX_INVALID_FILENAME". | |
63 */ | |
64 public String getServerErrorCodeSymbol() { | |
65 String[] detail = ErrorCodes.getDescription(sftpErrorCode); | |
273
91a31873c42a
start conversion from trilead to ganymed
Carl Byington <carl@five-ten-sg.com>
parents:
diff
changeset
|
66 |
307 | 67 if (detail == null) |
68 return "UNKNOWN SFTP ERROR CODE " + sftpErrorCode; | |
273
91a31873c42a
start conversion from trilead to ganymed
Carl Byington <carl@five-ten-sg.com>
parents:
diff
changeset
|
69 |
307 | 70 return detail[0]; |
71 } | |
273
91a31873c42a
start conversion from trilead to ganymed
Carl Byington <carl@five-ten-sg.com>
parents:
diff
changeset
|
72 |
307 | 73 /** |
74 * Get the description of the error code as given in the SFTP specs. | |
75 * | |
76 * @return e.g., "The filename is not valid." | |
77 */ | |
78 public String getServerErrorCodeVerbose() { | |
79 String[] detail = ErrorCodes.getDescription(sftpErrorCode); | |
273
91a31873c42a
start conversion from trilead to ganymed
Carl Byington <carl@five-ten-sg.com>
parents:
diff
changeset
|
80 |
307 | 81 if (detail == null) |
82 return "The error code " + sftpErrorCode + " is unknown."; | |
273
91a31873c42a
start conversion from trilead to ganymed
Carl Byington <carl@five-ten-sg.com>
parents:
diff
changeset
|
83 |
307 | 84 return detail[1]; |
85 } | |
273
91a31873c42a
start conversion from trilead to ganymed
Carl Byington <carl@five-ten-sg.com>
parents:
diff
changeset
|
86 } |