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

redefine error code as int64 #501

Merged
merged 1 commit into from
Nov 1, 2017

Conversation

Mashimiao
Copy link

Currently, error code is string type and duplicate with comment.
I think that's not good, we should change it.

Signed-off-by: Ma Shimiao mashimiao.fnst@cn.fujitsu.com

@Mashimiao
Copy link
Author

ping @liangchenye How do you think about it?

@liangchenye
Copy link
Member

I'm afraid if will be a huge code.

       DefaultFilesystems Code = 0xc << iota
  	// NSPathAbs represents "This value MUST be an absolute path in the runtime mount namespace."
       NSPathAbs

I did a test, the 50th number is 27021597764222976. I'm not sure one day it will be out of range.

Currently, error code is string type and duplicate with comment.
I think that's not good, we should change it.

Signed-off-by: Ma Shimiao <mashimiao.fnst@cn.fujitsu.com>
@Mashimiao
Copy link
Author

I changed them to 0x**** + iota. I think out of range will not be a problem any more.

@liangchenye
Copy link
Member

int is better than string in defining Code. But if we use int, when we add/update a *.go, we need to worry about whether there will be a collision. I just want to avoid this and decoupling different *.go files.

Another advantage is, if we want to tell the user what the code really mean, we just need to print it.

@Mashimiao
Copy link
Author

We get rfc code from spec documents, and classify them based on spec documents, so I think collision is hard to meet...
And in struct specerror.Error, we have Err which contains error message, printing Code seems not so necessary and we haven't printed Code at any place currently.

@liangchenye
Copy link
Member

I'm fine with this.
But I don't like 0xc << iota.
Can we make them a continuous codes in one .go file?

Just like http code, grouped by 2**, 4** .
In each group, the code is continuously.

@Mashimiao
Copy link
Author

I have changed it to Code = 0xc001 + iota, each group will be continuous.

@wking
Copy link
Contributor

wking commented Oct 26, 2017 via email

@Mashimiao
Copy link
Author

Mashimiao commented Oct 27, 2017 via email

@wking
Copy link
Contributor

wking commented Oct 27, 2017 via email

@Mashimiao
Copy link
Author

Mashimiao commented Oct 27, 2017 via email

@wking
Copy link
Contributor

wking commented Oct 27, 2017 via email

@liangchenye
Copy link
Member

liangchenye commented Nov 1, 2017

LGTM

Approved with PullApprove

1 similar comment
@zhouhao3
Copy link

zhouhao3 commented Nov 1, 2017

LGTM

Approved with PullApprove

@zhouhao3 zhouhao3 merged commit e2ffaf1 into opencontainers:master Nov 1, 2017
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

Successfully merging this pull request may close these issues.

4 participants