Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

beforeUpload 中 Promise.reject 的处理 #64

Closed
xiaodu527 opened this issue Feb 20, 2017 · 4 comments
Closed

beforeUpload 中 Promise.reject 的处理 #64

xiaodu527 opened this issue Feb 20, 2017 · 4 comments

Comments

@xiaodu527
Copy link

@shepherdwind

你好,我在 beforeUpload中 如果抛出了Promise.reject的异常,IE和火狐等浏览器都会出现
Unhandled promise rejection的错误;

能否在源码 AjaxUploader文件里面的upload方法里面:

if(before&&before.then) { before.then(...) }

添加一个异常捕获处理?

if(before&&before.then) { before.then(...).catch((err)=>{}) }

@shepherdwind
Copy link
Contributor

具体场景列一下,我感觉最好在 Promise 里面直接处理异常吧。不是很清楚为什么一定要在组件里面处理业务异常。

@xiaodu527
Copy link
Author

@shepherdwind
我要实现的功能是: 在图片上传之前对file进行压缩处理,并对选择的文件进行筛选
代码如下:
这是 beforeUpload 函数,

qq 20170220202301

我已经用 try catch进行了异常处理,并且在catch里面捕获到了异常,但是上图代码会出现下面的情况:

qq 20170220202121

虽然捕获到了异常,但是 还是上传了这个mp4文件;

只有在catch里面继续抛出异常才能终止这个文件的上传...不知道什么情况?

@shepherdwind
Copy link
Contributor

哦,我知道了,这里处理是有问题。

@shepherdwind
Copy link
Contributor

2.3.3 加了一个 catch

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants