You've already forked runc
mirror of
https://github.com/opencontainers/runc.git
synced 2026-10-23 19:49:01 +03:00
libct: use errors.AsType
Simplify error type inspection. For the benefits, see e.g. https://antonz.org/accepted/errors-astype/. Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
This commit is contained in:
@@ -1214,8 +1214,7 @@ func ignoreTerminateErrors(err error) error {
|
||||
// The (*Cmd).Wait documentation says: "If the command fails to run
|
||||
// or doesn't complete successfully, the error is of type *ExitError".
|
||||
// Filter out such errors (like "exit status 1" or "signal: killed").
|
||||
var exitErr *exec.ExitError
|
||||
if errors.As(err, &exitErr) {
|
||||
if _, ok := errors.AsType[*exec.ExitError](err); ok {
|
||||
return nil
|
||||
}
|
||||
if errors.Is(err, os.ErrProcessDone) {
|
||||
|
||||
@@ -49,8 +49,7 @@ func (p *restoredProcess) wait() (*os.ProcessState, error) {
|
||||
// maybe use --exec-cmd in criu
|
||||
err := p.cmd.Wait()
|
||||
if err != nil {
|
||||
var exitErr *exec.ExitError
|
||||
if !errors.As(err, &exitErr) {
|
||||
if _, ok := errors.AsType[*exec.ExitError](err); !ok {
|
||||
return nil, err
|
||||
}
|
||||
}
|
||||
|
||||
@@ -42,8 +42,7 @@ func testTransitions(t *testing.T, initialState containerState, valid []containe
|
||||
if err == nil {
|
||||
t.Fatal("transition should fail")
|
||||
}
|
||||
var stErr *stateTransitionError
|
||||
if !errors.As(err, &stErr) {
|
||||
if _, ok := errors.AsType[*stateTransitionError](err); !ok {
|
||||
t.Fatal("expected stateTransitionError")
|
||||
}
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user