Annotation Type Status


  • @Documented
    @Retention(RUNTIME)
    @Target(TYPE)
    public @interface Status
    Annotation for Throwable that map to HTTP error statuses. Its semantics is equivalent to an HTTP status line plus a related HTTP entity for errors.

    Example:
     @Get
     public MyBean represent() throws MyServerError, MyNotFoundError;
     
     @Status(500)
     public class MyServerError implements Throwable{
        ...
     }
     
     @Status(404, serialize = false)
     public class MyNotFoundError extends RuntimeException{
        ...
     }
     
     @Status(value = 400)
     public class MyBadParameterError extends RuntimeException{
        public String getParameterName() {
            ...
        };
        ...
     }
     
    Author:
    Jerome Louvel
    • Optional Element Summary

      Optional Elements 
      Modifier and Type Optional Element Description
      boolean serialize
      Indicates if the annotated Throwable should be serialized in the HTTP response entity.
      int value
      Specifies the HTTP status code associated to the annotated Throwable.
    • Element Detail

      • value

        int value
        Specifies the HTTP status code associated to the annotated Throwable. Default is 500.
        Returns:
        The result HTTP status code.
        Default:
        500
      • serialize

        boolean serialize
        Indicates if the annotated Throwable should be serialized in the HTTP response entity.
        Returns:
        True if Throwable should be serialized in the HTTP response entity.
        Default:
        true