Package com.azure.core.annotation
Annotation Type UnexpectedResponseExceptionType
-
@Retention(RUNTIME) @Target(METHOD) @Repeatable(UnexpectedResponseExceptionTypes.class) public @interface UnexpectedResponseExceptionType
The exception type that is thrown or returned when one of the status codes is returned from a REST API. Multiple annotations can be used. When no codes are listed that exception is always thrown or returned if it is reached during evaluation, this should be treated as a default case. If no default case is annotated the fall through exception isHttpResponseException.Example:
// Set it so that all response exceptions use a custom exception type. @UnexpectedResponseExceptionType(MyCustomExceptionHttpResponseException.class) @Post("subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/" + "Microsoft.CustomerInsights/hubs/{hubName}/images/getEntityTypeImageUploadUrl") void singleExceptionType(@PathParam("resourceGroupName") String resourceGroupName, @PathParam("hubName") String hubName, @PathParam("subscriptionId") String subscriptionId, @BodyParam("application/json") RequestBody parameters); // Set it so 404 uses a specific exception type while others use a generic exception type. @UnexpectedResponseExceptionType(code = {404}, value = ResourceNotFoundException.class) @UnexpectedResponseExceptionType(HttpResponseException.class) @Post("subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/" + "Microsoft.CustomerInsights/hubs/{hubName}/images/getEntityTypeImageUploadUrl") void multipleExceptionTypes(@PathParam("resourceGroupName") String resourceGroupName, @PathParam("hubName") String hubName, @PathParam("subscriptionId") String subscriptionId, @BodyParam("application/json") RequestBody parameters); // If multiple annotations share the same HTTP status code or there is multiple default annotations the // exception, the last annotation in the top to bottom order will be used (so the bottom most annotation).
-
-
Required Element Summary
Required Elements Modifier and Type Required Element Description Class<? extends HttpResponseException>valueThe type of HttpResponseException that should be thrown/returned when the API returns an unrecognized status code.
-
Optional Element Summary
Optional Elements Modifier and Type Optional Element Description int[]codeHTTP status codes which trigger the exception to be thrown or returned, if not status codes are listed the exception is always thrown or returned.
-
-
-
Element Detail
-
value
Class<? extends HttpResponseException> value
The type of HttpResponseException that should be thrown/returned when the API returns an unrecognized status code.- Returns:
- The type of RestException that should be thrown/returned.
-
-