Mercurial > 510Connectbot
comparison src/net/sourceforge/jsocks/SocksException.java @ 349:205ee2873330
update jsocks to 2011-03-19
author | Carl Byington <carl@five-ten-sg.com> |
---|---|
date | Fri, 01 Aug 2014 11:23:10 -0700 |
parents | 0ce5cc452d02 |
children | 3c16508419fe |
comparison
equal
deleted
inserted
replaced
348:29076621bab0 | 349:205ee2873330 |
---|---|
1 package net.sourceforge.jsocks; | 1 package net.sourceforge.jsocks; |
2 | 2 |
3 /** | 3 /** |
4 Exception thrown by various socks classes to indicate errors | 4 Exception thrown by various socks classes to indicate errors |
5 with protocol or unsuccessful server responses. | 5 with protocol or unsuccessfull server responses. |
6 */ | 6 */ |
7 public class SocksException extends java.io.IOException { | 7 public class SocksException extends java.io.IOException{ |
8 private static final long serialVersionUID = 6141184566248512277L; | 8 /** |
9 Construct a SocksException with given errorcode. | |
10 <p> | |
11 Tries to look up message which corresponds to this error code. | |
12 @param errCode Error code for this exception. | |
13 */ | |
14 public SocksException(int errCode){ | |
15 this.errCode = errCode; | |
16 if((errCode >> 16) == 0){ | |
17 //Server reply error message | |
18 errString = errCode <= serverReplyMessage.length ? | |
19 serverReplyMessage[errCode] : | |
20 UNASSIGNED_ERROR_MESSAGE; | |
21 }else{ | |
22 //Local error | |
23 errCode = (errCode >> 16) -1; | |
24 errString = errCode <= localErrorMessage.length ? | |
25 localErrorMessage[errCode] : | |
26 UNASSIGNED_ERROR_MESSAGE; | |
27 } | |
28 } | |
29 /** | |
30 Constructs a SocksException with given error code and message. | |
31 @param errCode Error code. | |
32 @param errString Error Message. | |
33 */ | |
34 public SocksException(int errCode,String errString){ | |
35 this.errCode = errCode; | |
36 this.errString = errString; | |
37 } | |
38 /** | |
39 Get the error code associated with this exception. | |
40 @return Error code associated with this exception. | |
41 */ | |
42 public int getErrorCode(){ | |
43 return errCode; | |
44 } | |
45 /** | |
46 Get human readable representation of this exception. | |
47 @return String represntation of this exception. | |
48 */ | |
49 public String toString(){ | |
50 return errString; | |
51 } | |
9 | 52 |
10 /** | 53 static final String UNASSIGNED_ERROR_MESSAGE = |
11 Construct a SocksException with given error code. | 54 "Unknown error message"; |
12 <p> | 55 static final String serverReplyMessage[] = { |
13 Tries to look up message which corresponds to this error code. | 56 "Succeeded", |
14 @param errCode Error code for this exception. | 57 "General SOCKS server failure", |
15 */ | 58 "Connection not allowed by ruleset", |
16 public SocksException(int errCode) { | 59 "Network unreachable", |
17 this.errCode = errCode; | 60 "Host unreachable", |
61 "Connection refused", | |
62 "TTL expired", | |
63 "Command not supported", | |
64 "Address type not supported" }; | |
18 | 65 |
19 if ((errCode >> 16) == 0) { | 66 static final String localErrorMessage[] ={ |
20 //Server reply error message | 67 "SOCKS server not specified", |
21 errString = errCode <= serverReplyMessage.length ? | 68 "Unable to contact SOCKS server", |
22 serverReplyMessage[errCode] : | 69 "IO error", |
23 UNASSIGNED_ERROR_MESSAGE; | 70 "None of Authentication methods are supported", |
24 } | 71 "Authentication failed", |
25 else { | 72 "General SOCKS fault" }; |
26 //Local error | |
27 errCode = (errCode >> 16) - 1; | |
28 errString = errCode <= localErrorMessage.length ? | |
29 localErrorMessage[errCode] : | |
30 UNASSIGNED_ERROR_MESSAGE; | |
31 } | |
32 } | |
33 /** | |
34 Constructs a SocksException with given error code and message. | |
35 @param errCode Error code. | |
36 @param errString Error Message. | |
37 */ | |
38 public SocksException(int errCode, String errString) { | |
39 this.errCode = errCode; | |
40 this.errString = errString; | |
41 } | |
42 /** | |
43 Get the error code associated with this exception. | |
44 @return Error code associated with this exception. | |
45 */ | |
46 public int getErrorCode() { | |
47 return errCode; | |
48 } | |
49 /** | |
50 Get human readable representation of this exception. | |
51 @return String represntation of this exception. | |
52 */ | |
53 public String toString() { | |
54 return errString; | |
55 } | |
56 | 73 |
57 static final String UNASSIGNED_ERROR_MESSAGE = | 74 String errString; |
58 "Unknown error message"; | 75 int errCode; |
59 static final String serverReplyMessage[] = { | |
60 "Succeeded", | |
61 "General SOCKS server failure", | |
62 "Connection not allowed by ruleset", | |
63 "Network unreachable", | |
64 "Host unreachable", | |
65 "Connection refused", | |
66 "TTL expired", | |
67 "Command not supported", | |
68 "Address type not supported" | |
69 }; | |
70 | |
71 static final String localErrorMessage[] = { | |
72 "SOCKS server not specified", | |
73 "Unable to contact SOCKS server", | |
74 "IO error", | |
75 "None of Authentication methods are supported", | |
76 "Authentication failed", | |
77 "General SOCKS fault" | |
78 }; | |
79 | |
80 String errString; | |
81 public int errCode; | |
82 | 76 |
83 }//End of SocksException class | 77 }//End of SocksException class |
84 | 78 |