use of cn.taketoday.http.converter.HttpMessageNotWritableException in project today-framework by TAKETODAY.
the class AbstractJsonHttpMessageConverter method writeInternal.
@Override
protected final void writeInternal(Object object, @Nullable Type type, HttpOutputMessage outputMessage) throws IOException, HttpMessageNotWritableException {
Writer writer = getWriter(outputMessage);
if (this.jsonPrefix != null) {
writer.append(this.jsonPrefix);
}
try {
writeInternal(object, type, writer);
} catch (Exception ex) {
throw new HttpMessageNotWritableException("Could not write JSON: " + ex.getMessage(), ex);
}
writer.flush();
}
use of cn.taketoday.http.converter.HttpMessageNotWritableException in project today-framework by TAKETODAY.
the class ResponseEntityExceptionHandlerTests method httpMessageNotWritable.
@Test
public void httpMessageNotWritable() {
Exception ex = new HttpMessageNotWritableException("");
testException(ex);
}
use of cn.taketoday.http.converter.HttpMessageNotWritableException in project today-framework by TAKETODAY.
the class AbstractWireFeedHttpMessageConverter method writeInternal.
@Override
protected void writeInternal(T wireFeed, HttpOutputMessage outputMessage) throws IOException, HttpMessageNotWritableException {
Charset charset = (StringUtils.isNotEmpty(wireFeed.getEncoding()) ? Charset.forName(wireFeed.getEncoding()) : DEFAULT_CHARSET);
MediaType contentType = outputMessage.getHeaders().getContentType();
if (contentType != null) {
contentType = new MediaType(contentType, charset);
outputMessage.getHeaders().setContentType(contentType);
}
WireFeedOutput feedOutput = new WireFeedOutput();
try {
Writer writer = new OutputStreamWriter(outputMessage.getBody(), charset);
feedOutput.output(wireFeed, writer);
} catch (FeedException ex) {
throw new HttpMessageNotWritableException("Could not write WireFeed: " + ex.getMessage(), ex);
}
}
use of cn.taketoday.http.converter.HttpMessageNotWritableException in project today-infrastructure by TAKETODAY.
the class AbstractWireFeedHttpMessageConverter method writeInternal.
@Override
protected void writeInternal(T wireFeed, HttpOutputMessage outputMessage) throws IOException, HttpMessageNotWritableException {
Charset charset = (StringUtils.isNotEmpty(wireFeed.getEncoding()) ? Charset.forName(wireFeed.getEncoding()) : DEFAULT_CHARSET);
MediaType contentType = outputMessage.getHeaders().getContentType();
if (contentType != null) {
contentType = new MediaType(contentType, charset);
outputMessage.getHeaders().setContentType(contentType);
}
WireFeedOutput feedOutput = new WireFeedOutput();
try {
Writer writer = new OutputStreamWriter(outputMessage.getBody(), charset);
feedOutput.output(wireFeed, writer);
} catch (FeedException ex) {
throw new HttpMessageNotWritableException("Could not write WireFeed: " + ex.getMessage(), ex);
}
}
use of cn.taketoday.http.converter.HttpMessageNotWritableException in project today-infrastructure by TAKETODAY.
the class AbstractJsonHttpMessageConverter method writeInternal.
@Override
protected final void writeInternal(Object object, @Nullable Type type, HttpOutputMessage outputMessage) throws IOException, HttpMessageNotWritableException {
Writer writer = getWriter(outputMessage);
if (this.jsonPrefix != null) {
writer.append(this.jsonPrefix);
}
try {
writeInternal(object, type, writer);
} catch (Exception ex) {
throw new HttpMessageNotWritableException("Could not write JSON: " + ex.getMessage(), ex);
}
writer.flush();
}
Aggregations