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

一处bug望看一下 #24

Open
Macrohoo opened this issue Aug 28, 2020 · 4 comments
Open

一处bug望看一下 #24

Macrohoo opened this issue Aug 28, 2020 · 4 comments

Comments

@Macrohoo
Copy link

async saveNew() {
const { ctx } = this;
try {
const rule = {
merchant: "object",
};
ctx.validate(rule);
const uuid = await ctx.service.user.merchant.saveNew(ctx.request.body);
this.success(uuid);
} catch (err) {
const { fields = {}, name } = err;
if (name === "SequelizeUniqueConstraintError") {
this.fail(ctx.UNIQUE_CODE, 账号:${fields.userName} 的商家已存在);
} else {
throw new Error(err);
}
}
}

在这段代码中如果抓取err且确实抓取到Unique的错误,确实会报(账号:undefined 的商家已存在)的错误.
可是在后续更换一个账号名去再次注册,且保证账号名是唯一的前提,依旧会报(账号:undefined 的商家已存在)的错误.
if (name === "SequelizeUniqueConstraintError") {} 应该是不能用这种方式去捕获错误吧?

@Macrohoo
Copy link
Author

还有可能bug是不是出在model.create()失败时
的结果处理中遗漏了reject和catch部分

@Macrohoo
Copy link
Author

而导致的数据库阻塞原因?

@ruiyong-lee
Copy link
Owner

你好,这个项目基本是我学习的过程,后端代码有的地方写的不成熟或者错误,这里的确不该这么判断,应该有其他更精确的判断

@Macrohoo
Copy link
Author

我也是刚在学 前辈有比较成熟基于egg,mysql的商城项目吗? 最好像这份一样带有单页面vue cms系统的

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