Uploaded image for project: 'Spring Framework'
  1. Spring Framework
  2. SPR-12888

Better exception message for missing @RequestBody method parameter

    Details

    • Type: Improvement
    • Status: Closed
    • Priority: Minor
    • Resolution: Complete
    • Affects Version/s: 4.1.3
    • Fix Version/s: 4.2 RC1
    • Component/s: None
    • Labels:
      None
    • Last commented by a User:
      true

      Description

      When I use @RequestBody on one of my controllers for a required parameter, I need some useful way of saying which parameter was missing if it's not there. The exception message I see currently looks like this:

      Required request body content is missing: org.springframework.web.method.HandlerMethod$HandlerMethodParameter@a8b8886e
      	at org.springframework.test.util.MatcherAssertionErrors.assertThat(MatcherAssertionErrors.java:80)
      	at org.springframework.test.util.JsonPathExpectationsHelper.assertValue(JsonPathExpectationsHelper.java:92)
      	at org.springframework.test.web.servlet.result.JsonPathResultMatchers$1.match(JsonPathResultMatchers.java:56)
      	at org.springframework.test.web.servlet.MockMvc$1.andExpect(MockMvc.java:152)
      ...
      

      It would be nice if when that exception could have a reference to the parameter name that was missing, or if the message itself included it instead of the MethodParameter#toString(). I'll eventually want to internationalize the message I produce, so the parameter name is preferable.

        Attachments

          Activity

            People

            • Assignee:
              rstoya05-aop Rossen Stoyanchev
              Reporter:
              elreydetodo Martin Meyer
              Last updater:
              Spring Issuemaster
            • Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved:
                Days since last comment:
                31 weeks, 4 days ago