Package io.dropwizard.jersey.errors
Class ErrorEntityWriter<T,U>
java.lang.Object
io.dropwizard.jersey.errors.ErrorEntityWriter<T,U>
- Type Parameters:
T- The entity type to handleU- The response type to produce
- All Implemented Interfaces:
jakarta.ws.rs.ext.MessageBodyWriter<T>
public abstract class ErrorEntityWriter<T,U>
extends Object
implements jakarta.ws.rs.ext.MessageBodyWriter<T>
This class allows producing non-JSON responses for particular entities. For example, register an instance with the
ErrorMessage entity and the TEXT_HTML MediaType to produce custom HTML error messages.-
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedErrorEntityWriter(jakarta.ws.rs.core.MediaType contentType, Class<U> representation) -
Method Summary
Modifier and TypeMethodDescriptionprotected abstract UgetRepresentation(T entity) longgetSize(T entity, Class<?> type, Type genericType, Annotation[] annotations, jakarta.ws.rs.core.MediaType mediaType) booleanisWriteable(Class<?> type, Type genericType, Annotation[] annotations, jakarta.ws.rs.core.MediaType mediaType) voidwriteTo(T entity, Class<?> type, Type genericType, Annotation[] annotations, jakarta.ws.rs.core.MediaType mediaType, jakarta.ws.rs.core.MultivaluedMap<String, Object> responseHeaders, OutputStream entityStream)
-
Constructor Details
-
ErrorEntityWriter
- Parameters:
contentType- Content type the writer will producerepresentation- Response type the writer will produce
-
-
Method Details
-
isWriteable
public boolean isWriteable(Class<?> type, Type genericType, Annotation[] annotations, jakarta.ws.rs.core.MediaType mediaType) - Specified by:
isWriteablein interfacejakarta.ws.rs.ext.MessageBodyWriter<T>
-
getSize
public long getSize(T entity, Class<?> type, Type genericType, Annotation[] annotations, jakarta.ws.rs.core.MediaType mediaType) - Specified by:
getSizein interfacejakarta.ws.rs.ext.MessageBodyWriter<T>
-
writeTo
public void writeTo(T entity, Class<?> type, Type genericType, Annotation[] annotations, jakarta.ws.rs.core.MediaType mediaType, jakarta.ws.rs.core.MultivaluedMap<String, Object> responseHeaders, OutputStream entityStream) throws IOException, jakarta.ws.rs.WebApplicationException- Specified by:
writeToin interfacejakarta.ws.rs.ext.MessageBodyWriter<T>- Throws:
IOExceptionjakarta.ws.rs.WebApplicationException
-
getRepresentation
-