Annotation to specify multiple UnexpectedResponseExceptionType
See original GitHub issueIs your feature request related to a problem? Please describe. The REST Proxy should be able to throw richer exception depending on the error code returned by service.
Describe the solution you’d like Define an annotation, that can be used to define multiple exception types and map each exception type to error codes.
An example usage looks like:
@UnexpectedResponseExceptionTypes({
@UnexpectedResponseExceptionTypes.Type(code = {333}, value = Exception333.class),
@UnexpectedResponseExceptionTypes.Type(code = {345, 346}, value = RestException.class),
@UnexpectedResponseExceptionTypes.Type(value = ServiceRequestException.class)
})
The annotation looks like:
public @interface UnexpectedResponseExceptionTypes {
public Type[] value();
public @interface Type {
public int[] code() default { };
public Class<?> value();
}
}
The above grouping is needed only in java 7 and below, java 8+ supports repeated annotations. Switching to the experience that @JonathanGiles originally proposed.
Reference: see this discussion.
Example usage:
@UnexpectedResponseExceptionType(code = {333}, value = Exception333.class),
@UnexpectedResponseExceptionType(code = {345, 346}, value = RestException.class),
@UnexpectedResponseExceptionType(value = ServiceRequestException.class)
Annotation definition:
public @interface UnexpectedResponseExceptionType {
public Class<?> value();
public int[] code() default { };
}
Information Checklist Kindly make sure that you have added all the following information above and checkoff the required fields otherwise we will treat the issuer as an incomplete report
- Description Added
- Expected solution specified
Issue Analytics
- State:
- Created 4 years ago
- Comments:9 (9 by maintainers)
Yes it does 😃 https://docs.oracle.com/javase/tutorial/java/annotations/repeating.html
@jianghaolu will work on this.