IotHubExceptionManager Class

  • java.lang.Object
    • com.microsoft.azure.sdk.iot.service.exceptions.IotHubExceptionManager

public class IotHubExceptionManager

Provide static function to verify results and throw appropriate exception.

Method Summary

Modifier and Type Method and Description
void httpResponseVerification(HttpResponse httpResponse)

Verify Http response using response status

IotHubException mapException(int responseStatus, String description)

Return a new exception instance that best matches the given HTTP status code and description

Method Details

httpResponseVerification

public static void httpResponseVerification(HttpResponse httpResponse)

Verify Http response using response status

Parameters:

httpResponse - Http response object to verify

Throws:

IotHubBadFormatException - This exception is thrown if the response status equal 400
IotHubUnauthorizedException - This exception is thrown if the response status equal 401
IotHubTooManyDevicesException - This exception is thrown if the response status equal 403
IotHubNotFoundException - This exception is thrown if the response status equal 404
IotHubPreconditionFailedException - This exception is thrown if the response status equal 412
IotHubTooManyRequestsException - This exception is thrown if the response status equal 429
IotHubInternalServerErrorException - This exception is thrown if the response status equal 500
IotHubBadGatewayException - This exception is thrown if the response status equal 502
IotHubServerBusyException - This exception is thrown if the response status equal 503
IotHubGatewayTimeoutException - This exception is thrown if the response status equal 504
IotHubException - This exception is thrown if the response status none of them above and greater then 300

mapException

public static IotHubException mapException(int responseStatus, String description)

Return a new exception instance that best matches the given HTTP status code and description

Parameters:

responseStatus - The HTTP status code (404, 500, etc.)
description - The HTTP response body

Returns:

a new exception instance that best matches the given HTTP status code

Applies to