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.

有帮助吗?

解决方案

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.

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top