Comments (3)
推荐解决方案
自己继承RuntimeException 实现一个ServiceException。
public class ServiceException extends RuntimeException {
private Object data;
public ServiceException(String message) {
super(message);
}
public ServiceException(String message, Object data) {
super(message);
this.data = data;
}
public ServiceException(String message, Throwable cause) {
super(message, cause);
}
public Object getData() {
return this.data;
}
public void setData(Object data) {
this.data = data;
}
}
然后实现WebMvcConfigurer 进行统一异常处理。
具体可以参考这篇博文
https://www.cnblogs.com/gdwkong/p/8969963.html
正确的写法是
try
{
//do something
}
catch(Exception e)
{
//do something handle the exception
log.error("do something error",e);
//返回到前端的内容会根据你实现的WebMvcConfigurer 类封装成你想要的形式
throw new ServiceException("UPLOAD ERROR");
}
from kiftd-source.
kiftd的源代码中确实还存在很多设计缺陷,您提到的异常处理就是其中一类。当初很多异常都是只考虑了它对前端用户产生的影响,因此只做了基本的逻辑反馈。您给出的建议已经阅读,在后续优化代码(如果有时间的话)时会作为参考,不过,一般而言这一过程可能需要很长的时间了。
再次感谢您的反馈,这是kiftd不断进步的最佳动力。
from kiftd-source.
@81519434 @KOHGYLW 建议两位可以达成一个共识,就是 @81519434 可以 fork 一份进行相应的改进,完成后 PR 到 @KOHGYLW ,而主干在开发过程中尽量保持不再引入类似的使用。
from kiftd-source.
Related Issues (20)
- 加入Trash功能
- 支持webdav,nfs 等协议 HOT 1
- Springboot升级到2.4以上
- Jackson 2.9.5 版本有远程代码执行漏洞
- Java版本
- 请问文件路径是一一对应的吗? HOT 4
- web端无法导出文件夹(打包导出也不可以) HOT 1
- 启动遇到问题,成功运行过一次,把UI界面的文本修改过后(即输出文本)出现无法以UI界面运行错误
- 可以直接支持mysql数据库吗 HOT 1
- 想请问一下作者关于用户数据是如何用h2DB存储的?能否换成mysql? HOT 2
- 想问一下作者有做隐藏端口号的想法吗?以及关于api的一些想法 HOT 1
- 请问为什么没有做分页呢,是有什么特殊考量吗
- 上传大文件失败,报错
- jar和exe文件无法上传
- 【功能】 多线程下载添加,webdav也加上 HOT 1
- 图形界面模式启动失败 HOT 2
- API接口速度过慢
- 视频转码修改调用CPU数量以及调用GPU转码 HOT 1
- 功能建议 HOT 1
- 添加更多类型文件预览 HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from kiftd-source.