Skip to content

Commit b9d03f7

Browse files
author
Caitlin Bales (MSFT)
committed
Remove errorCode parameter from exception
1 parent 99e5196 commit b9d03f7

File tree

13 files changed

+11
-48
lines changed

13 files changed

+11
-48
lines changed

src/main/java/com/microsoft/graph/core/ClientException.java

Lines changed: 1 addition & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -27,28 +27,13 @@
2727
*/
2828
public class ClientException extends RuntimeException {
2929

30-
/**
31-
* The error code for this exception.
32-
*/
33-
private final GraphErrorCodes errorCode;
34-
3530
/**
3631
* Creates the client exception.
3732
* @param message The message to display.
3833
* @param ex The exception from.
3934
* @param errorCode The error code for this exception.
4035
*/
41-
public ClientException(final String message, final Throwable ex, final GraphErrorCodes errorCode) {
36+
public ClientException(final String message, final Throwable ex) {
4237
super(message, ex);
43-
this.errorCode = errorCode;
44-
}
45-
46-
/**
47-
* Determines if the given error code is expected.
48-
* @param expectedCode The expected error code.
49-
* @return true if the error code matches, and false if there was no match.
50-
*/
51-
public boolean isError(final GraphErrorCodes expectedCode) {
52-
return this.errorCode == expectedCode;
5338
}
5439
}

src/main/java/com/microsoft/graph/http/BaseRequest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -153,7 +153,7 @@ public URL getRequestUrl() {
153153
try {
154154
return new URL(uriBuilder.build().toString());
155155
} catch (final MalformedURLException e) {
156-
throw new ClientException("Invalid URL: " + uriBuilder.toString(), e, GraphErrorCodes.INVALID_REQUEST);
156+
throw new ClientException("Invalid URL: " + uriBuilder.toString(), e);
157157
}
158158
}
159159

src/main/java/com/microsoft/graph/http/DefaultHttpProvider.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -335,8 +335,7 @@ private <Result, Body, DeserializeType> Result sendRequestInternal(final IHttpRe
335335
throw ex;
336336
} catch (final Exception ex) {
337337
final ClientException clientException = new ClientException("Error during http request",
338-
ex,
339-
GraphErrorCodes.GENERAL_EXCEPTION);
338+
ex);
340339
logger.logError("Error during http request", clientException);
341340
throw clientException;
342341
}

src/main/java/com/microsoft/graph/http/GraphFatalServiceException.java

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -29,11 +29,6 @@
2929
*/
3030
public class GraphFatalServiceException extends GraphServiceException {
3131

32-
/**
33-
* The web site to report issues on this SDK.
34-
*/
35-
public static final String SDK_BUG_URL = "https://github.com/microsoftgraph/msgraph-sdk-java/issues";
36-
3732
/**
3833
* Create a fatal Graph service exception.
3934
* @param method The method that caused the exception.

src/main/java/com/microsoft/graph/http/GraphServiceException.java

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,7 @@ protected GraphServiceException(final String method,
125125
final String responseMessage,
126126
final List<String> responseHeaders,
127127
final GraphErrorResponse error) {
128-
super(responseMessage, null, null);
128+
super(responseMessage, null);
129129
this.method = method;
130130
this.url = url;
131131
this.requestHeaders = requestHeaders;
@@ -216,14 +216,6 @@ public GraphError getServiceError() {
216216
return error.error;
217217
}
218218

219-
@Override
220-
public boolean isError(final GraphErrorCodes expectedCode) {
221-
if (getServiceError() != null) {
222-
return getServiceError().isError(expectedCode);
223-
}
224-
return false;
225-
}
226-
227219
/**
228220
* Creates a Graph service exception from a given failed HTTP request.
229221
*

src/main/java/com/microsoft/graph/requests/extensions/ChunkedUploadRequest.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,6 @@ public <UploadType> ChunkedUploadResult upload(
124124
}
125125

126126
return new ChunkedUploadResult(
127-
new ClientException("Upload session failed to many times.", null,
128-
GraphErrorCodes.UPLOAD_SESSION_INCOMPLETE));
127+
new ClientException("Upload session failed to many times.", null));
129128
}
130129
}

src/main/java/com/microsoft/graph/requests/extensions/ChunkedUploadResult.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ public ChunkedUploadResult(ClientException error) {
6767
* @param exception The exception received from server.
6868
*/
6969
public ChunkedUploadResult(GraphServiceException exception) {
70-
this(new ClientException(exception.getMessage(/* verbose */ true), exception, GraphErrorCodes.UPLOAD_SESSION_FAILED));
70+
this(new ClientException(exception.getMessage(/* verbose */ true), exception));
7171
}
7272

7373
/**

src/test/java/com/microsoft/graph/concurrency/DefaultExecutorsTests.java

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@
77
import org.junit.Test;
88

99
import com.microsoft.graph.core.ClientException;
10-
import com.microsoft.graph.core.GraphErrorCodes;
1110
import com.microsoft.graph.logger.MockLogger;
1211

1312
import java.util.concurrent.atomic.AtomicBoolean;
@@ -95,14 +94,13 @@ public void testPerformOnForegroundWithClientException() {
9594
final String expectedLogMessage = "Starting foreground task, current active count:0, with exception com.microsoft.graph.core.ClientException: client exception message";
9695
final ExecutorTestCallback<String> callback = new ExecutorTestCallback<>();
9796

98-
defaultExecutors.performOnForeground(new ClientException(expectedExceptionMessage,null, GraphErrorCodes.INVALID_ACCEPT_TYPE),
97+
defaultExecutors.performOnForeground(new ClientException(expectedExceptionMessage,null),
9998
callback);
10099

101100
callback._completionWaiter.waitForSignal();
102101
assertFalse(callback._successCalled.get());
103102
assertTrue(callback._failureCalled.get());
104103
assertEquals(expectedExceptionMessage, callback._exceptionResult.get().getMessage());
105-
assertTrue(callback._exceptionResult.get().isError(GraphErrorCodes.INVALID_ACCEPT_TYPE));
106104
assertEquals(1,mLogger.getLogMessages().size());
107105
assertTrue(mLogger.hasMessage(expectedLogMessage));
108106
}

src/test/java/com/microsoft/graph/core/ClientExceptionTests.java

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,14 +8,12 @@
88

99
public class ClientExceptionTests {
1010

11-
private GraphErrorCodes graphErrorCodes;
1211
private ClientException clientException;
1312
private String expectMessage = "This is test exception message";
1413

1514
@Before
1615
public void setUp() throws Exception {
17-
graphErrorCodes = GraphErrorCodes.ACCESS_DENIED;
18-
clientException = new ClientException(expectMessage, null, graphErrorCodes);
16+
clientException = new ClientException(expectMessage, null);
1917
}
2018

2119
@Test
@@ -25,7 +23,6 @@ public void testNotNull() {
2523

2624
@Test
2725
public void testClientException() {
28-
assertTrue(clientException.isError(graphErrorCodes));
2926
assertEquals(expectMessage, clientException.getMessage());
3027
}
3128

src/test/java/com/microsoft/graph/http/DefaultHttpProviderTests.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -259,7 +259,6 @@ public Map<String, String> getHeaders() {
259259
mProvider.send(new MockHttpRequest(), DriveItem.class, null);
260260
fail("Expected exception in previous statement");
261261
} catch (final GraphServiceException e) {
262-
assertTrue(e.isError(expectedErrorCode));
263262
assertEquals(expectedMessage, e.getServiceError().message);
264263
}
265264
}

0 commit comments

Comments
 (0)