spring-projects / spring-projects/spring-data-rest

When an exception is thrown it is not getting returned in JSON even with AnnotationMethodHandlerExceptionResolver [DATAREST-139]

Open
#527 0 comments 0 reactions 1 assignee View on GitHub

@odrotbohm is already working on this.

Since Dec 31, 2020.

type: bug
Dominant language
Java
Stars
958
Forks
568
PR merge metrics
No merged PRs in 30d

Description

Thomas Darimont opened DATAREST-139 and commented

Github Author: vijaygrk
Github Last-Updated: 2013-03-25T01:45:30Z
This issue was automatically imported from github

Here is what i have in my application config.
The response type is always set to text/html when an exception is thrown

@Bean
public StringHttpMessageConverter stringHttpMessageConverter() {
    return new StringHttpMessageConverter();
}

@Bean
public MappingJacksonHttpMessageConverter jsonHttpMessageConverter() {
    return new MappingJacksonHttpMessageConverter();
}

@Bean
public AnnotationMethodHandlerExceptionResolver methodHandlerExceptionResolver() {
    AnnotationMethodHandlerExceptionResolver annotationMethodHandlerExceptionResolver = new
            AnnotationMethodHandlerExceptionResolver();
    annotationMethodHandlerExceptionResolver.setOrder(1);
    HttpMessageConverter[] messageConvertersList = {jsonHttpMessageConverter()};
    annotationMethodHandlerExceptionResolver.setMessageConverters(messageConvertersList);
    return annotationMethodHandlerExceptionResolver;
}

Reference URL: https://api.github.com/repos/SpringSource/spring-data-rest/issues/84

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.