定义错误代码的规则?
我正在开发一个项目,在该项目中,如果工作失败,我需要返回错误代码。 但这样做的“规则”是什么?
例如:
if(tryDoUpload() == false) {
//upload failed
int UPLOAD_FAILED = 0x0;
}
参见0x0
,是否有设置此错误代码的模式或者我可以设置任何模式吗?
我希望这一点很清楚。
I'm working on a project in which I need to return error codes in case work failed.
But which is the 'rule' for doing this?
For example:
if(tryDoUpload() == false) {
//upload failed
int UPLOAD_FAILED = 0x0;
}
see 0x0
, is there a pattern to set this error code or can I set any?
I hope this is clear.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
没有可供您使用的标准错误代码集。您可以自由地制作自己的。话虽这么说,错误代码对用户来说不太友好。如果您正在使用一个软件,您希望看到什么:“上传失败,错误代码 0x00deadbeef”或“上传失败,已存在具有该名称的文件”。您应该更愿意为用户提供有意义的错误消息。
there is no standard set of error codes for you to use. you are free to make your own. that being said, error codes are not very user friendly. if you are using a piece of software what would YOU want to see: "upload failed, error code 0x00deadbeef" or "upload failed, a file with that name all ready exists." you should prefer to give the user meaningful error messages.