Skip to content

[Refactor] Move exit_coder from cmd to pkg/errutil#1857

Merged
AkihiroSuda merged 1 commit into
containerd:mainfrom
Laitr0n:refactor_exit_coder
Jan 17, 2023
Merged

[Refactor] Move exit_coder from cmd to pkg/errutil#1857
AkihiroSuda merged 1 commit into
containerd:mainfrom
Laitr0n:refactor_exit_coder

Conversation

@Laitr0n
Copy link
Copy Markdown
Contributor

@Laitr0n Laitr0n commented Jan 16, 2023

Checklist:

  • move ExitCodeError from cmd to pkg/exitcoderpkg/errutil

return ExitCodeError{
exitCode: int(code),
}
}

When I refactor the container start command, I have discovered that ExitCodeError from cmd is blocking my work.

nerdctl/cmd/nerdctl/main.go

Lines 343 to 367 in 0b051a5

type ExitCoder interface {
error
ExitCode() int
}
type ExitCodeError struct {
error
exitCode int
}
func (e ExitCodeError) ExitCode() int {
return e.exitCode
}
func HandleExitCoder(err error) {
if err == nil {
return
}
if exitErr, ok := err.(ExitCoder); ok {
os.Exit(exitErr.ExitCode())
}
}

Maybe we should refactor ExitCodeError first, by moving it to pkg/exitcoder. Then we can continue with our other tasks.

Signed-off-by: Laitron meetlq@outlook.com

@Laitr0n Laitr0n marked this pull request as ready for review January 16, 2023 15:55
@Laitr0n
Copy link
Copy Markdown
Contributor Author

Laitr0n commented Jan 16, 2023

@AkihiroSuda @Zheaoli @djdongjin PTLA

@AkihiroSuda AkihiroSuda added this to the v1.2.0 milestone Jan 17, 2023
Comment thread pkg/exitcoder/exit_coder.go
Signed-off-by: Laitron <meetlq@outlook.com>
@Laitr0n Laitr0n force-pushed the refactor_exit_coder branch from aeee957 to efb501c Compare January 17, 2023 02:34
@Laitr0n Laitr0n changed the title [Refactor] Move exit_coder from cmd to pkg/exitcoder [Refactor] Move exit_coder from cmd to pkg/errutil Jan 17, 2023
@Laitr0n Laitr0n requested a review from AkihiroSuda January 17, 2023 02:37
Copy link
Copy Markdown
Member

@AkihiroSuda AkihiroSuda left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants