Replies: 1 comment 1 reply
-
When the SDK throws an exception like this, the service's error message is saved as the thrown exception's try
{
registryClient.getDevice("someDeviceId");
}
catch (IotHubException e)
{
//error code from the service. For example, 404
System.out.println(e.getErrorCode());
//human readable error code derived from the integer status code above. For example, "NotFound"
System.out.println(e.getErrorCodeDescription());
// human readable error message from the service. For example: "The requested device could not be found. Tracking ID: _______"
System.out.println(e.getMessage());
} |
Beta Was this translation helpful? Give feedback.
1 reply
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Hi,
while we get IotHubException for some reason, we get the errorCode and the errorCodeDescription, but they look to be modified by SDK. How we can get the actual Hub error message?
For example:
catch(ex:IotHubException) {
ex.errorCode and ex.errorCodeDescription // gives -> errorCode: 409, errorCodeDescription : Conflict
}
But when we print the exception ex, we get
"
Exception IoTHub Error: com.microsoft.azure.sdk.iot.service.exceptions.IotHubConflictException: ErrorCode:DeviceAlreadyExists;A device with ID 'new-device-from-ui-1' is already registered. Tracking ID:xxxxxxxxxxxxxxxxxxxxxx-G:0-TimeStamp:10/19/2022 05:12:00
"
Now, I would like to get the
is there a API to get them? Using String on it does not feel like a good option, as it can change in future?
Beta Was this translation helpful? Give feedback.
All reactions