Skip to content

GlobalDefaultExceptionHandler异常message缺失具体异常信息 #5366

Description

@youngzil

描述bug

  1. 在前台批量修改时,如果有一个注释太长,超过了数据库的长度,最终得到的返回报文如下,缺失了最根本的报错信息
{
    "exception": "org.springframework.dao.DataIntegrityViolationException",
    "message": "could not execute statement; SQL [n/a]; nested exception is org.hibernate.exception.DataException: could not execute statement",
    "status": 500.0,
    "timestamp": "2025-03-26T15:04:11.69"
}

Image

  1. 通过后台代码可以看出来,

实际实现是 org.springframework.core.NestedRuntimeException#getMessage,只处理了2层包装异常
Image

  1. 缺失了最根本的message :Data too long for column 'Comment' at row 1
    Image

复现
通过如下步骤可以复现:

期望

简介明了地描述你希望正常情况下应该发生什么

截图

如果可以,附上截图来描述你的问题

额外的细节和日志

  • 版本:
  • 错误日志
  • 配置:
  • 平台和操作系统

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions