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

数据库模型层的error返回值处理不恰当 #13

Open
voidint opened this issue Dec 27, 2016 · 0 comments
Open

数据库模型层的error返回值处理不恰当 #13

voidint opened this issue Dec 27, 2016 · 0 comments

Comments

@voidint
Copy link
Contributor

voidint commented Dec 27, 2016

manufacturer, err := repo.GetManufacturerBySn(row.Sn)
if err != nil {
    w.WriteJSON(map[string]interface{}{"Status": "error", "Message": "参数错误" + err.Error()})
    return
}

类似以上这样的错误处理方式,如果调用数据层接口,一旦返回error就认定是参数错误是不合适的。举个反例:如果db挂了,那么调用数据层一定会返回error,这时候把原因归结为参数错误,显然就不合适了。

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

1 participant