Better exception message for missing @RequestBody method parameter
https://jira.spring.io/browse/SPR-12888
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.
Activity
- All
- Comments
- Work Log
- History
- Activity
- Transitions
The HttpMessageNotReadableException can be raised from many places where a method parameter does not apply so adding a new field to the exception isn't ideal. I considered sub-classing the exception but what I've done instead is to print the full method signature to improve the error message. Also we now support injecting the selected HandlerMethod into an @ExceptionHandler method so you can obtain the full information on the @RequestMapping method we were trying to call.
Resolving for now but feel free to comment further.
Better exception message for missing @RequestBody method parameter的更多相关文章
- CAS (10) —— JBoss EAP 6.4下部署CAS时出现错误exception.message=Error decoding flow execution的解决办法
CAS (10) -- JBoss EAP 6.4下部署CAS时出现错误exception.message=Error decoding flow execution的解决办法 jboss版本: jb ...
- Use Exception.ToString() instead of Exception.Message.
Exception.Message contains only the message (doh) associated with the exception. Example: Object ref ...
- java.lang.Exception: No tests found matching Method tes(com.bw.test.Testrefiect) from org.junit.vintage.engine.descriptor.RunnerRequest@3bfdc050 at org.junit.internal.requests.FilterRequest.getRunner
junit 方法 没有加上注解 @Test java.lang.Exception: No tests found matching Method tes(com.bw.test.Testre ...
- jenkins编辑报错Exception when publishing, exception message的解决办法
jenkins编辑报错Exception when publishing, exception message的解决办法 查看目标主机的磁盘空间是否占满,清理磁盘空间即可
- Exception message: /bin/bash: line 0: fg: no job control
这个错误是 我本地idea 远程调试hadoop集群出现的 Diagnostics: Exception from container-launch. Container id: container_ ...
- 记一次Jenkins 打包异常 ERROR: Exception when publishing, exception message [Failure]
今天早上打包一直都没有问题,突然有一次打包突然出现异常现象,如下: ERROR: Exception when publishing, exception message [Failure] Buil ...
- 错误:java.lang.Exception: No tests found matching Method testPrePage1(egou_manager_web.TestEBrand) from org.junit.internal.requests.ClassRequest@4f3cc73c
今天测试分页时出现以下错误: java.lang.Exception: No tests found matching Method testPrePage1(egou_manager_web.Tes ...
- How to receive JSON as an MVC 5 action method parameter
How to receive JSON as an MVC 5 action method parameter 解答1 Unfortunately, Dictionary has problems ...
- Yarn报错:Exception message: /bin/bash: line 0: fg: no job control
Exception message: /bin/bash: line 0: fg: no job control 这个错误是 本地idea跨平台远程调试hadoop集群出现的,在使用windows调用 ...
随机推荐
- 2019.03.22 读书笔记 var object dynamic
var:语法糖,在编译时推断出类型,根据反编译可以看出.实际用处是增加代码的健壮性,比如 linq ,匿名对象等. object:很多人容易和var混淆,其实概念上完全不同,没什么可比性. dynam ...
- express --- session详解
之前一直做前端相关的工作,所以不太清楚session,也没有主动了解,最近在学node,对session的认识又有所加深,故总结之. 注: 关于session的一些配置问题,可以看这里. 第一部分: ...
- Beam内置的数据源清单(Java、Python)
不多说,直接上干货! Beam内置的Java数据源清单: Beam内置的Python数据源清单:
- spring DelegatingFilterProxy管理过滤器
安全过滤器链 Spring Security的web架构是完全基于标准的servlet过滤器的.它没有在内部使用servlet或任何其他基于servlet的框架(比如spring mvc),所以它没有 ...
- ApplicationContextAware的作用
ApplicationContextAware其实我们看到---Aware就知道是干嘛用的了,就是属性注入的, 但是这个ApplicationContextAware的不同地方在于,实现了这个接口的b ...
- maven实战迷你版记录
1. ~/.m2 文件 默认情况下,该文件夹下放置了 Maven 本地 仓库.m2/repository.所有的 Maven 构件(artifact)都被存储到该仓库中,以方便重用. 默认情况下,~ ...
- pat1093. Count PAT's (25)
1093. Count PAT's (25) 时间限制 120 ms 内存限制 65536 kB 代码长度限制 16000 B 判题程序 Standard 作者 CAO, Peng The strin ...
- win8中如何设定editplus为txt默认打开程序
设定EditPlus为TXT默认打开方式吧. 首选,打开我们的EditPlus 接着,点击[工具]菜单,点击[参数设置]这个菜单项 来到设定界面 找到[设置&语法]这个选项,然后可以看到里面有 ...
- java虚拟机之GC(转)
垃圾回收主要内容: 1. 那些内存需要回收? 2. 什么时候回收? 3. 如何回收? 垃圾回收主要针对运行时数据区那些区域? 运行时数据区的线程私有区域有:虚拟机栈,本地方法栈,程序计数器等: 栈中的 ...
- (开发)ESLint - 代码规范
参考文档:http://eslint.cn/ ESLint 是在 ECMAScript/JavaScript 代码中识别和报告模式匹配的工具,它的目标是保证代码的一致性和避免错误.在许多方面,它和 J ...