Skip to content

Commit 9b2885f

Browse files
author
André Behrens (serious6)
committed
improve some Exception classes + javadoc
- Adding deprecated API for duplicated exceptions (they already exist java.lang.Exception) - (small) improvement for ArgumentException - @throws EWSHttpException the eWS http exception -> @throws EWSHttpException the EWS http exception - removed commented (deadcode) as mentioned in review - some parts reformatted as they where not in place
1 parent 8049db6 commit 9b2885f

16 files changed

Lines changed: 312 additions & 287 deletions

src/main/java/microsoft/exchange/webservices/data/autodiscover/AutodiscoverService.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -373,7 +373,7 @@ private void writeLegacyAutodiscoverRequest(String emailAddress,
373373
*
374374
* @param domainName the domain name
375375
* @return A valid SSL-enabled redirection URL. (May be null)
376-
* @throws EWSHttpException the eWS http exception
376+
* @throws EWSHttpException the EWS http exception
377377
* @throws XMLStreamException the XML stream exception
378378
* @throws IOException Signals that an I/O exception has occurred.
379379
* @throws ServiceLocalException the service local exception
@@ -440,7 +440,7 @@ private URI getRedirectUrl(String domainName)
440440
* @return true if a valid redirection URL was found
441441
* @throws XMLStreamException the XML stream exception
442442
* @throws IOException signals that an I/O exception has occurred.
443-
* @throws EWSHttpException the eWS http exception
443+
* @throws EWSHttpException the EWS http exception
444444
*/
445445
private boolean tryGetRedirectionResponse(HttpWebRequest request,
446446
OutParam<URI> redirectUrl) throws XMLStreamException, IOException,
@@ -1570,7 +1570,7 @@ private boolean tryGetEnabledEndpointsForHost(String host,
15701570
*
15711571
* @param request the request
15721572
* @return Endpoints enabled.
1573-
* @throws EWSHttpException the eWS http exception
1573+
* @throws EWSHttpException the EWS http exception
15741574
*/
15751575
private EnumSet<AutodiscoverEndpoints> getEndpointsFromHttpWebResponse(
15761576
HttpWebRequest request) throws EWSHttpException {
@@ -1617,7 +1617,7 @@ private EnumSet<AutodiscoverEndpoints> getEndpointsFromHttpWebResponse(
16171617
* @param memoryStream the memory stream
16181618
* @throws XMLStreamException the XML stream exception
16191619
* @throws IOException signals that an I/O exception has occurred.
1620-
* @throws EWSHttpException the eWS http exception
1620+
* @throws EWSHttpException the EWS http exception
16211621
*/
16221622
public void traceResponse(HttpWebRequest request, ByteArrayOutputStream memoryStream) throws XMLStreamException,
16231623
IOException, EWSHttpException {

src/main/java/microsoft/exchange/webservices/data/autodiscover/request/AutodiscoverRequest.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ protected AutodiscoverRequest(AutodiscoverService service, URI url) {
9393
*
9494
* @param request the request
9595
* @return True if redirection response.
96-
* @throws EWSHttpException the eWS http exception
96+
* @throws EWSHttpException the EWS http exception
9797
*/
9898
public static boolean isRedirectionResponse(HttpWebRequest request)
9999
throws EWSHttpException {
@@ -324,7 +324,7 @@ private void processWebException(Exception exception, HttpWebRequest req) {
324324
* @return AutodiscoverResponse autodiscoverResponse object
325325
* @throws XMLStreamException the XML stream exception
326326
* @throws IOException signals that an I/O exception has occurred
327-
* @throws EWSHttpException the eWS http exception
327+
* @throws EWSHttpException the EWS http exception
328328
*/
329329
private AutodiscoverResponse createRedirectionResponse(
330330
HttpWebRequest httpWebResponse) throws XMLStreamException,
@@ -559,7 +559,7 @@ protected void writeBodyToXml(EwsServiceXmlWriter writer)
559559
*
560560
* @param request the request
561561
* @return ResponseStream
562-
* @throws EWSHttpException the eWS http exception
562+
* @throws EWSHttpException the EWS http exception
563563
* @throws IOException signals that an I/O exception has occurred.
564564
*/
565565
protected static InputStream getResponseStream(HttpWebRequest request)

src/main/java/microsoft/exchange/webservices/data/autodiscover/request/GetUserSettingsRequest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -265,7 +265,7 @@ protected void writeElementsToXml(EwsServiceXmlWriter writer)
265265
/**
266266
* Read the partner token soap header.
267267
*
268-
* @param reader eWS XML reader
268+
* @param reader EWS XML reader
269269
* @throws Exception on error
270270
*/
271271
@Override

src/main/java/microsoft/exchange/webservices/data/core/EwsUtilities.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -573,7 +573,7 @@ public static String formatLogMessage(String entryKind, String logEntry)
573573
*
574574
* @param response the response
575575
* @return the string
576-
* @throws EWSHttpException the eWS http exception
576+
* @throws EWSHttpException the EWS http exception
577577
*/
578578
public static String formatHttpResponseHeaders(HttpWebRequest response)
579579
throws EWSHttpException {

src/main/java/microsoft/exchange/webservices/data/core/ExchangeServiceBase.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -422,7 +422,7 @@ public void traceXml(TraceFlags traceType, ByteArrayOutputStream stream) {
422422
*
423423
* @param traceType Kind of trace entry.
424424
* @param request The request
425-
* @throws EWSHttpException eWS http exception
425+
* @throws EWSHttpException EWS http exception
426426
* @throws URISyntaxException URI syntax error
427427
* @throws IOException signals that an I/O exception has occurred
428428
* @throws XMLStreamException the XML stream exception
@@ -444,7 +444,7 @@ public void traceHttpRequestHeaders(TraceFlags traceType, HttpWebRequest request
444444
* @param request the HttpRequest object
445445
* @throws XMLStreamException the XML stream exception
446446
* @throws IOException signals that an I/O exception has occurred
447-
* @throws EWSHttpException the eWS http exception
447+
* @throws EWSHttpException the EWS http exception
448448
*/
449449
private void traceHttpResponseHeaders(TraceFlags traceType, HttpWebRequest request)
450450
throws XMLStreamException, IOException, EWSHttpException {
@@ -778,7 +778,7 @@ public void setOnSerializeCustomSoapHeaders(List<ICustomXmlSerialization> onSeri
778778
*
779779
* @param traceType kind of trace entry
780780
* @param request The request
781-
* @throws EWSHttpException eWS http exception
781+
* @throws EWSHttpException EWS http exception
782782
* @throws IOException signals that an I/O exception has occurred
783783
* @throws XMLStreamException the XML stream exception
784784
*/

src/main/java/microsoft/exchange/webservices/data/core/exception/http/EWSHttpException.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -34,15 +34,15 @@ public class EWSHttpException extends Exception {
3434
private static final long serialVersionUID = 1L;
3535

3636
/**
37-
* Instantiates a new eWS http exception.
37+
* Instantiates a new EWS http exception.
3838
*/
3939
public EWSHttpException() {
4040
super();
4141

4242
}
4343

4444
/**
45-
* Instantiates a new eWS http exception.
45+
* Instantiates a new EWS http exception.
4646
*
4747
* @param arg0 the arg0
4848
* @param arg1 the arg1
@@ -53,7 +53,7 @@ public EWSHttpException(String arg0, Throwable arg1) {
5353
}
5454

5555
/**
56-
* Instantiates a new eWS http exception.
56+
* Instantiates a new EWS http exception.
5757
*
5858
* @param arg0 the arg0
5959
*/
@@ -63,7 +63,7 @@ public EWSHttpException(String arg0) {
6363
}
6464

6565
/**
66-
* Instantiates a new eWS http exception.
66+
* Instantiates a new EWS http exception.
6767
*
6868
* @param arg0 the arg0
6969
*/

src/main/java/microsoft/exchange/webservices/data/core/exception/misc/ArgumentException.java

Lines changed: 84 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -23,56 +23,120 @@
2323

2424
package microsoft.exchange.webservices.data.core.exception.misc;
2525

26+
import java.security.PrivilegedActionException;
27+
2628
/**
2729
* The Class ArgumentException.
2830
*/
29-
public class ArgumentException extends Exception {
31+
public class ArgumentException extends IllegalArgumentException {
3032

3133
/**
3234
* Constant serialized ID used for compatibility.
3335
*/
34-
private static final long serialVersionUID = 1L;
36+
private static final long serialVersionUID = 2L;
37+
38+
/**
39+
* ParamName that causes the Exception
40+
*/
41+
private String paramName = null;
3542

3643
/**
37-
* Instantiates a new argument exception.
44+
* Constructs an <code>IllegalArgumentException</code> with no detail message.
3845
*/
39-
public ArgumentException() {
46+
protected ArgumentException() {
4047
super();
48+
}
4149

50+
/**
51+
* Constructs an <code>IllegalArgumentException</code> with the specified detail message.
52+
*
53+
* @param message the detail message.
54+
*/
55+
public ArgumentException(String message) {
56+
super(message);
4257
}
4358

4459
/**
45-
* Instantiates a new argument exception.
60+
* Constructs an <code>IllegalArgumentException</code> with the specified detail message.
4661
*
47-
* @param arg0 the arg0
62+
* @param s the detail message.
63+
* @param paramName the Name of the Param that causes the exception
4864
*/
49-
public ArgumentException(final String arg0) {
50-
super(arg0);
65+
public ArgumentException(String s, String paramName) {
66+
super(s);
67+
this.paramName = paramName;
68+
}
5169

70+
/**
71+
* Constructs a new exception with the specified detail message and cause.
72+
* <p/>
73+
* <p>Note that the detail message associated with <code>cause</code> is <i>not</i> automatically
74+
* incorporated in this exception's detail message.
75+
*
76+
* @param message the detail message (which is saved for later retrieval by the {@link
77+
* Throwable#getMessage()} method).
78+
* @param cause the cause (which is saved for later retrieval by the {@link Throwable#getCause()} method).
79+
* (A <tt>null</tt> value is permitted, and indicates that the cause is nonexistent or
80+
* unknown.)
81+
* @since 1.5
82+
*/
83+
public ArgumentException(String message, Throwable cause) {
84+
super(message, cause);
85+
}
86+
87+
/**
88+
* Constructs a new exception with the specified cause and a detail message of <tt>(cause==null ? null :
89+
* cause.toString())</tt> (which typically contains the class and detail message of <tt>cause</tt>). This
90+
* constructor is useful for exceptions that are little more than wrappers for other throwables (for
91+
* example, {@link PrivilegedActionException}).
92+
*
93+
* @param cause the cause (which is saved for later retrieval by the {@link Throwable#getCause()} method).
94+
* (A <tt>null</tt> value is permitted, and indicates that the cause is nonexistent or
95+
* unknown.)
96+
* @since 1.5
97+
*/
98+
public ArgumentException(Throwable cause) {
99+
super(cause);
52100
}
53101

54102
/**
55-
* ServiceXmlDeserializationException Constructor.
103+
* Constructs a new exception with the specified cause and a detail message of <tt>(cause==null ? null :
104+
* cause.toString())</tt> (which typically contains the class and detail message of <tt>cause</tt>). This
105+
* constructor is useful for exceptions that are little more than wrappers for other throwables (for
106+
* example, {@link PrivilegedActionException}).
56107
*
57-
* @param message the message
58-
* @param innerException the inner exception
108+
* @param cause the cause (which is saved for later retrieval by the {@link Throwable#getCause()}
109+
* method). (A <tt>null</tt> value is permitted, and indicates that the cause is
110+
* nonexistent or unknown.)
111+
* @param paramName the Name of the Param that causes the exception
59112
*/
60-
public ArgumentException(String message, Exception innerException) {
61-
super(message, innerException);
113+
public ArgumentException(Throwable cause, String paramName) {
114+
super(cause);
115+
this.paramName = paramName;
62116
}
63117

64118
/**
65-
* Initializes a new instance of the System.
66-
* ArgumentException class with a specified
67-
* error message and the name of the
68-
* parameter that causes this exception.
119+
* Initializes a new instance of the System. ArgumentException class with a specified error message and the
120+
* name of the parameter that causes this exception.
69121
*
70122
* @param message The error message that explains the reason for the exception.
71-
* @param paramName The name of the parameter that caused the current exception.
123+
* @param cause the cause (which is saved for later retrieval by the {@link Throwable#getCause()}
124+
* method). (A <tt>null</tt> value is permitted, and indicates that the cause is
125+
* nonexistent or unknown.)
126+
* @param paramName the Name of the Param that causes the exception
72127
*/
73-
public ArgumentException(String message, String paramName) {
128+
public ArgumentException(String message, Throwable cause, String paramName) {
74129
super(message + " Parameter that caused " +
75-
"the current exception :" + paramName);
130+
"the current exception :" + paramName);
131+
this.paramName = paramName;
132+
}
133+
134+
/**
135+
* Get the Name of the Param that causes the exception
136+
* @return the ParamName (or null if not set)
137+
*/
138+
public String getParamName() {
139+
return paramName;
76140
}
77141

78142
}

src/main/java/microsoft/exchange/webservices/data/core/exception/misc/ArgumentNullException.java

Lines changed: 58 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -23,52 +23,85 @@
2323

2424
package microsoft.exchange.webservices.data.core.exception.misc;
2525

26-
/**
27-
* The Class ArgumentNullException.
28-
*/
29-
public class ArgumentNullException extends Exception {
26+
public class ArgumentNullException extends ArgumentException {
3027

3128
/**
32-
* Constant serialized ID used for compatibility.
29+
* Constructs an <code>IllegalArgumentException</code> with the specified detail message.
30+
*
31+
* @param message the detail message.
3332
*/
34-
private static final long serialVersionUID = 1L;
33+
public ArgumentNullException(String message) {
34+
super(message);
35+
}
3536

3637
/**
37-
* Instantiates a new argument null exception.
38+
* Constructs an <code>IllegalArgumentException</code> with the specified detail message.
39+
*
40+
* @param s the detail message.
41+
* @param paramName the Name of the Param that causes the exception
3842
*/
39-
public ArgumentNullException() {
40-
super();
41-
43+
public ArgumentNullException(String s, String paramName) {
44+
super(s, paramName);
4245
}
4346

4447
/**
45-
* Instantiates a new argument null exception.
48+
* Constructs a new exception with the specified detail message and cause.
49+
* <p/>
50+
* <p>Note that the detail message associated with <code>cause</code> is <i>not</i> automatically
51+
* incorporated in this exception's detail message.
4652
*
47-
* @param arg0 the arg0
48-
* @param arg1 the arg1
53+
* @param message the detail message (which is saved for later retrieval by the {@link
54+
* Throwable#getMessage()} method).
55+
* @param cause the cause (which is saved for later retrieval by the {@link Throwable#getCause()} method).
56+
* (A <tt>null</tt> value is permitted, and indicates that the cause is nonexistent or
57+
* unknown.)
58+
* @since 1.5
4959
*/
50-
public ArgumentNullException(final String arg0, final Throwable arg1) {
51-
super(arg0, arg1);
52-
60+
public ArgumentNullException(String message, Throwable cause) {
61+
super(message, cause);
5362
}
5463

5564
/**
56-
* Instantiates a new argument null exception.
65+
* Constructs a new exception with the specified cause and a detail message of <tt>(cause==null ? null :
66+
* cause.toString())</tt> (which typically contains the class and detail message of <tt>cause</tt>). This
67+
* constructor is useful for exceptions that are little more than wrappers for other throwables (for
68+
* example, {@link PrivilegedActionException}).
5769
*
58-
* @param arg0 the arg0
70+
* @param cause the cause (which is saved for later retrieval by the {@link Throwable#getCause()} method).
71+
* (A <tt>null</tt> value is permitted, and indicates that the cause is nonexistent or
72+
* unknown.)
73+
* @since 1.5
5974
*/
60-
public ArgumentNullException(final String arg0) {
61-
super(arg0);
62-
75+
public ArgumentNullException(Throwable cause) {
76+
super(cause);
6377
}
6478

6579
/**
66-
* Instantiates a new argument null exception.
80+
* Constructs a new exception with the specified cause and a detail message of <tt>(cause==null ? null :
81+
* cause.toString())</tt> (which typically contains the class and detail message of <tt>cause</tt>). This
82+
* constructor is useful for exceptions that are little more than wrappers for other throwables (for
83+
* example, {@link PrivilegedActionException}).
6784
*
68-
* @param arg0 the arg0
85+
* @param cause the cause (which is saved for later retrieval by the {@link Throwable#getCause()}
86+
* method). (A <tt>null</tt> value is permitted, and indicates that the cause is
87+
* nonexistent or unknown.)
88+
* @param paramName the Name of the Param that causes the exception
6989
*/
70-
public ArgumentNullException(final Throwable arg0) {
71-
super(arg0);
90+
public ArgumentNullException(Throwable cause, String paramName) {
91+
super(cause, paramName);
92+
}
7293

94+
/**
95+
* Initializes a new instance of the System. ArgumentException class with a specified error message and the
96+
* name of the parameter that causes this exception.
97+
*
98+
* @param message The error message that explains the reason for the exception.
99+
* @param cause the cause (which is saved for later retrieval by the {@link Throwable#getCause()}
100+
* method). (A <tt>null</tt> value is permitted, and indicates that the cause is
101+
* nonexistent or unknown.)
102+
* @param paramName the Name of the Param that causes the exception
103+
*/
104+
public ArgumentNullException(String message, Throwable cause, String paramName) {
105+
super(message, cause, paramName);
73106
}
74107
}

0 commit comments

Comments
 (0)