-
Couldn't load subscription status.
- Fork 30
Description
Expected behavior
When a GraphError's code field has the value "ErrorItemNotFound", then GrapError#isError method should return true for GraphErrorCodes.ITEM_NOT_FOUND.
Actual behavior
I have a catch-block for a GraphServiceException and I'm checking the error code that is returned. This check uses GraphError#isError. For GraphErrorCodes.ITEM_NOT_FOUND this check returns false, whereas the log shows:
CoreHttpProvider[sendRequestInternal] - 408Graph service exception
Throwable detail: com.microsoft.graph.http.GraphServiceException: Error code: ErrorItemNotFound
Error message: The specified object was not found in the store.
Steps to reproduce the behavior
- Create code similar to the code below and verify that for a non-existing Event ID it will return a GraphServiceException with code "ErrorItemNotFound", yet it will not log the line as stated in the exception.
`
try
{
graphServiceClient.users(resourceIdentifier) //
.events(eventId)//
.decline(EventDeclineParameterSet.newBuilder().withSendResponse(false).build())
.buildRequest()//
.post();
// Decline it twice to get the ErrorItemNotFound exception
graphServiceClient.users(resourceIdentifier) //
.events(eventId)//
.decline(EventDeclineParameterSet.newBuilder().withSendResponse(false).build())
.buildRequest()//
.post();
LOG.info(String.format("Declined event for ID <%s> for Resource <%s>", eventId, resourceIdentifier), aContext);
}
catch (GraphServiceException aException)
{
// Item not found so nothing to decline, proceed as if it was a success
if (aException.getServiceError().isError(GraphErrorCodes.ITEM_NOT_FOUND))
{
LOG.info(String.format("No need to decline event for ID <%s> for Resource <%s> as it was already not present", eventId, resourceIdentifier), aContext);
}
}
`
Expected solution
Expected problem is the comparison made in GraphError#transformErrorCodeCase
Where "ErrorItemNotFound" is compared to ITEM_NOT_FOUND, this yields false as either the code should have been "ItemNotFound" or GraphErrorCodes.ERROR_ITEM_NOT_FOUND should have existed.