@@ -0,0 +1,1724 @@
+package uk.ac.ebi.biosamples.service;%0A%0Aimport java.io.IOException;%0Aimport java.io.PrintWriter;%0Aimport java.util.Arrays;%0Aimport java.util.List;%0A%0Aimport org.slf4j.Logger;%0Aimport org.slf4j.LoggerFactory;%0Aimport org.springframework.http.HttpInputMessage;%0Aimport org.springframework.http.HttpOutputMessage;%0Aimport org.springframework.http.MediaType;%0Aimport org.springframework.http.converter.AbstractHttpMessageConverter;%0Aimport org.springframework.http.converter.HttpMessageNotReadableException;%0Aimport org.springframework.http.converter.HttpMessageNotWritableException;%0A%0Aimport uk.ac.ebi.biosamples.model.Sample;%0A%0Apublic class ExceptionAsTextHttpMessageConverter extends AbstractHttpMessageConverter%3CException%3E %7B%0A%09%0A%09private final List%3CMediaType%3E DEFAULT_SUPPORTED_MEDIA_TYPES = Arrays.asList(MediaType.TEXT_PLAIN);%0A%0A%09private Logger log = LoggerFactory.getLogger(getClass());%0A%0A%09public ExceptionAsTextHttpMessageConverter() %7B%0A%09%09this.setSupportedMediaTypes(this.DEFAULT_SUPPORTED_MEDIA_TYPES);%0A%09%7D%0A%0A%09@Override%0A%09protected boolean supports(Class%3C?%3E clazz) %7B%0A%09%09return Sample.class.isAssignableFrom(clazz);%0A%09%7D%0A%0A%09@Override%0A%09protected Exception readInternal(Class%3C? extends Exception%3E clazz, HttpInputMessage inputMessage)%0A%09%09%09throws IOException, HttpMessageNotReadableException %7B%0A%09%09throw new HttpMessageNotReadableException(%22Cannot read exceptions%22); %0A%09%7D%0A%0A%09@Override%0A%09protected void writeInternal(Exception exception, HttpOutputMessage outputMessage)%0A%09%09%09throws IOException, HttpMessageNotWritableException %7B%0A%09%09log.trace(%22Writing message%22);%0A%09%09PrintWriter printWritter = new PrintWriter(outputMessage.getBody());%0A%09%09exception.printStackTrace(printWritter);%0A%09%09//don't close the writer, underlying outputstream will be closed elsewhere%0A%09%7D%0A%0A%7D%0A

fix to render exceptions as text responses