feat: Errorf usage

Signed-off-by: haoyun <yun.hao@daocloud.io>
This commit is contained in:
haoyun
2021-12-13 14:31:53 +08:00
parent a04656c1dd
commit c0d07094be
30 changed files with 80 additions and 80 deletions

View File

@@ -32,27 +32,27 @@ type deletedState struct {
}
func (s *deletedState) Pause(ctx context.Context) error {
return errors.Errorf("cannot pause a deleted process")
return errors.New("cannot pause a deleted process")
}
func (s *deletedState) Resume(ctx context.Context) error {
return errors.Errorf("cannot resume a deleted process")
return errors.New("cannot resume a deleted process")
}
func (s *deletedState) Update(context context.Context, r *google_protobuf.Any) error {
return errors.Errorf("cannot update a deleted process")
return errors.New("cannot update a deleted process")
}
func (s *deletedState) Checkpoint(ctx context.Context, r *CheckpointConfig) error {
return errors.Errorf("cannot checkpoint a deleted process")
return errors.New("cannot checkpoint a deleted process")
}
func (s *deletedState) Resize(ws console.WinSize) error {
return errors.Errorf("cannot resize a deleted process")
return errors.New("cannot resize a deleted process")
}
func (s *deletedState) Start(ctx context.Context) error {
return errors.Errorf("cannot start a deleted process")
return errors.New("cannot start a deleted process")
}
func (s *deletedState) Delete(ctx context.Context) error {
@@ -68,7 +68,7 @@ func (s *deletedState) SetExited(status int) {
}
func (s *deletedState) Exec(ctx context.Context, path string, r *ExecConfig) (Process, error) {
return nil, errors.Errorf("cannot exec in a deleted state")
return nil, errors.New("cannot exec in a deleted state")
}
func (s *deletedState) Status(ctx context.Context) (string, error) {

View File

@@ -107,11 +107,11 @@ func (s *execRunningState) Resize(ws console.WinSize) error {
}
func (s *execRunningState) Start(ctx context.Context) error {
return errors.Errorf("cannot start a running process")
return errors.New("cannot start a running process")
}
func (s *execRunningState) Delete(ctx context.Context) error {
return errors.Errorf("cannot delete a running process")
return errors.New("cannot delete a running process")
}
func (s *execRunningState) Kill(ctx context.Context, sig uint32, all bool) error {
@@ -145,11 +145,11 @@ func (s *execStoppedState) transition(name string) error {
}
func (s *execStoppedState) Resize(ws console.WinSize) error {
return errors.Errorf("cannot resize a stopped container")
return errors.New("cannot resize a stopped container")
}
func (s *execStoppedState) Start(ctx context.Context) error {
return errors.Errorf("cannot start a stopped process")
return errors.New("cannot start a stopped process")
}
func (s *execStoppedState) Delete(ctx context.Context) error {

View File

@@ -60,11 +60,11 @@ func (s *createdState) transition(name string) error {
}
func (s *createdState) Pause(ctx context.Context) error {
return errors.Errorf("cannot pause task in created state")
return errors.New("cannot pause task in created state")
}
func (s *createdState) Resume(ctx context.Context) error {
return errors.Errorf("cannot resume task in created state")
return errors.New("cannot resume task in created state")
}
func (s *createdState) Update(ctx context.Context, r *google_protobuf.Any) error {
@@ -72,7 +72,7 @@ func (s *createdState) Update(ctx context.Context, r *google_protobuf.Any) error
}
func (s *createdState) Checkpoint(ctx context.Context, r *CheckpointConfig) error {
return errors.Errorf("cannot checkpoint a task in created state")
return errors.New("cannot checkpoint a task in created state")
}
func (s *createdState) Start(ctx context.Context) error {
@@ -129,11 +129,11 @@ func (s *createdCheckpointState) transition(name string) error {
}
func (s *createdCheckpointState) Pause(ctx context.Context) error {
return errors.Errorf("cannot pause task in created state")
return errors.New("cannot pause task in created state")
}
func (s *createdCheckpointState) Resume(ctx context.Context) error {
return errors.Errorf("cannot resume task in created state")
return errors.New("cannot resume task in created state")
}
func (s *createdCheckpointState) Update(ctx context.Context, r *google_protobuf.Any) error {
@@ -141,7 +141,7 @@ func (s *createdCheckpointState) Update(ctx context.Context, r *google_protobuf.
}
func (s *createdCheckpointState) Checkpoint(ctx context.Context, r *CheckpointConfig) error {
return errors.Errorf("cannot checkpoint a task in created state")
return errors.New("cannot checkpoint a task in created state")
}
func (s *createdCheckpointState) Start(ctx context.Context) error {
@@ -211,7 +211,7 @@ func (s *createdCheckpointState) SetExited(status int) {
}
func (s *createdCheckpointState) Exec(ctx context.Context, path string, r *ExecConfig) (Process, error) {
return nil, errors.Errorf("cannot exec in a created state")
return nil, errors.New("cannot exec in a created state")
}
func (s *createdCheckpointState) Status(ctx context.Context) (string, error) {
@@ -250,7 +250,7 @@ func (s *runningState) Pause(ctx context.Context) error {
}
func (s *runningState) Resume(ctx context.Context) error {
return errors.Errorf("cannot resume a running process")
return errors.New("cannot resume a running process")
}
func (s *runningState) Update(ctx context.Context, r *google_protobuf.Any) error {
@@ -262,11 +262,11 @@ func (s *runningState) Checkpoint(ctx context.Context, r *CheckpointConfig) erro
}
func (s *runningState) Start(ctx context.Context) error {
return errors.Errorf("cannot start a running process")
return errors.New("cannot start a running process")
}
func (s *runningState) Delete(ctx context.Context) error {
return errors.Errorf("cannot delete a running process")
return errors.New("cannot delete a running process")
}
func (s *runningState) Kill(ctx context.Context, sig uint32, all bool) error {
@@ -306,7 +306,7 @@ func (s *pausedState) transition(name string) error {
}
func (s *pausedState) Pause(ctx context.Context) error {
return errors.Errorf("cannot pause a paused container")
return errors.New("cannot pause a paused container")
}
func (s *pausedState) Resume(ctx context.Context) error {
@@ -326,11 +326,11 @@ func (s *pausedState) Checkpoint(ctx context.Context, r *CheckpointConfig) error
}
func (s *pausedState) Start(ctx context.Context) error {
return errors.Errorf("cannot start a paused process")
return errors.New("cannot start a paused process")
}
func (s *pausedState) Delete(ctx context.Context) error {
return errors.Errorf("cannot delete a paused process")
return errors.New("cannot delete a paused process")
}
func (s *pausedState) Kill(ctx context.Context, sig uint32, all bool) error {
@@ -350,7 +350,7 @@ func (s *pausedState) SetExited(status int) {
}
func (s *pausedState) Exec(ctx context.Context, path string, r *ExecConfig) (Process, error) {
return nil, errors.Errorf("cannot exec in a paused state")
return nil, errors.New("cannot exec in a paused state")
}
func (s *pausedState) Status(ctx context.Context) (string, error) {
@@ -372,23 +372,23 @@ func (s *stoppedState) transition(name string) error {
}
func (s *stoppedState) Pause(ctx context.Context) error {
return errors.Errorf("cannot pause a stopped container")
return errors.New("cannot pause a stopped container")
}
func (s *stoppedState) Resume(ctx context.Context) error {
return errors.Errorf("cannot resume a stopped container")
return errors.New("cannot resume a stopped container")
}
func (s *stoppedState) Update(ctx context.Context, r *google_protobuf.Any) error {
return errors.Errorf("cannot update a stopped container")
return errors.New("cannot update a stopped container")
}
func (s *stoppedState) Checkpoint(ctx context.Context, r *CheckpointConfig) error {
return errors.Errorf("cannot checkpoint a stopped container")
return errors.New("cannot checkpoint a stopped container")
}
func (s *stoppedState) Start(ctx context.Context) error {
return errors.Errorf("cannot start a stopped process")
return errors.New("cannot start a stopped process")
}
func (s *stoppedState) Delete(ctx context.Context) error {
@@ -407,7 +407,7 @@ func (s *stoppedState) SetExited(status int) {
}
func (s *stoppedState) Exec(ctx context.Context, path string, r *ExecConfig) (Process, error) {
return nil, errors.Errorf("cannot exec in a stopped state")
return nil, errors.New("cannot exec in a stopped state")
}
func (s *stoppedState) Status(ctx context.Context) (string, error) {