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调用 ...
随机推荐
- ubuntu 修改hostname
1.sudo gedit /etc/hostname 2. 修改成你的新名字,例如 SS1 3. 保存,退出 3. sudo gedit /etc/hosts 4修改成心的名字 SS1 5. 保存,退 ...
- linux查看当前用户登陆信息
@(Linux基础)[linux查看当前用户登陆信息] linux查看当前用户登陆信息 作为系统管理员,你可能经常会(在某个时候)需要查看系统中有哪些用户正在活动.有些时候,你甚至需要知道他(她)们正 ...
- Tiles框架入门教程
1.为何选用Tiles 刚接触Java Web开发的人都知道,JSP中可以通过include标签动态插入一个JSP页面.在了解这个功能后可能会兴奋不已,因为这样可以实现多个JSP页面共用一个JSP的内 ...
- Linux环境常用命令
bash host #查看IP对应机器名 hostname #查看本机名 hostname –i #查看本机IP mssh ...
- Murano Weekly Meeting 2015.12.01
Meeting time: 2015.December.1st 1:00~2:00 Chairperson: Nikolay Starodubtsev, from Mirantis Meeting ...
- express --- session详解
之前一直做前端相关的工作,所以不太清楚session,也没有主动了解,最近在学node,对session的认识又有所加深,故总结之. 注: 关于session的一些配置问题,可以看这里. 第一部分: ...
- Git常用配置
Git设置默认用户名和密码 1.进入C:\users\Administrator目录下,通过git bash终端输入touch .git-credentials后回车2.打开生成的.git-crede ...
- 【计算机网络】一步一步学习IP路由流程
TCP/IP协议簇是目前互联网应用最广的协议栈,谈到TCP/IP协议栈就不能不讲一讲IP路由的问题,因为在我们使用的网络通信中几乎每时每刻都在发生着IP路由的事件…….当你在网络世界中还是一位新手的时 ...
- ThreadPoolExecutor的三种队列SynchronousQueue,LinkedBlockingQueue,ArrayBlockingQueue
SynchronousQueue SynchronousQueue是无界的,是一种无缓冲的等待队列,但是由于该Queue本身的特性,在某次添加元素后必须等待其他线程取走后才能继续添加:可以认为Sync ...
- 如何修改FlashFXP默认编辑工具使用记事本打开
FlashFXP如果不设置默认编辑工具,那么当你打开html文档的时候,默认会用word打开,很不方便,其实简单的设置下,可以默认以任何工具打开.具体设置方法如下: 选项>>关联文件. 然 ...