-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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
async/await封装使用mysql 中错误处理的问题 #2
Comments
谢谢指正错误,已经修改好了,O(∩_∩)O! |
谢谢提醒,改好了,O(∩_∩)O |
msyql发生异常时,只在db-utils.js中调用reject(),但是没有在上层调用的地方捕获异常,会触发unhandledpromiserejectionwarning。 |
db-utils.js中增加catch,实现全局处理
或者在models里进行局部处理
但是有一个问题,再捕获到异常后,怎么将异常提示给controller并返回,有什么好的处理方式? app.js中错误处理,可以参考阮一峰老师的例子
|
https://github.com/ChenShenhai/koa2-note/blob/master/note/mysql/async.md
下面的代码中,如果创建连接失败,应该是
reject( err )
吧?The text was updated successfully, but these errors were encountered: