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:
@UnexpectedResponseExceptionType(MyCustomException.class) @POST("subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft .CustomerInsights/hubs/{hubName}/images/getEntityTypeImageUploadUrl") void getUploadUrlForEntityType(@Path("resourceGroupName") String resourceGroupName, @Path("hubName") String hubName, @Path("subscriptionId") String subscriptionId, @Body GetImageUploadUrlInputInner parameters); @UnexpectedResponseExceptionType(code = {404}, value = NotFoundException.class) @UnexpectedResponseExceptionType(DefaultException.class) @POST("subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft .CustomerInsights/hubs/{hubName}/images/getEntityTypeImageUploadUrl") void getUploadUrlForEntityType(@Path("resourceGroupName") String resourceGroupName, @Path("hubName") String hubName, @Path("subscriptionId") String subscriptionId, @Body GetImageUploadUrlInputInner parameters);
If multiple annotations share the same HTTP status code or there is multiple default annotations the exception from the last annotation in the top to bottom order will be used.
-
-
Required Element Summary
Required Elements Modifier and Type Required Element Description Class<? extends HttpResponseException>
value
The 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[]
code
HTTP 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.
-
-