Skip to content

Commit 2fc2cb1

Browse files
committed
lint: Add more specification on overused error message
Right now, it's difficult to locate which ReadState() function call failed. This will improve the failure location process Signed-off-by: Yejin Seo <yejseo01@arm.com>
1 parent 2784306 commit 2fc2cb1

4 files changed

Lines changed: 5 additions & 5 deletions

File tree

internal/runtime/delete.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ func Delete(logger *slog.Logger, containerID string, force bool) error {
2222
func delete(containerID string) error {
2323
state, err := oci.ReadState(containerID)
2424
if err != nil {
25-
return fmt.Errorf("failed to read state 1: %w", err)
25+
return fmt.Errorf("failed to read state while delete: %w", err)
2626
}
2727

2828
if state.Status == specs.StateRunning {
@@ -41,7 +41,7 @@ func delete(containerID string) error {
4141
func forceDelete(logger *slog.Logger, containerID string) {
4242
state, err := oci.ReadState(containerID)
4343
if err != nil {
44-
logger.Error("failed to read state 2", "error", err)
44+
logger.Error("failed to read state while force delete", "error", err)
4545
return
4646
}
4747

internal/runtime/kill.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ import (
1212
func Kill(containerID string, signal syscall.Signal) error {
1313
state, err := oci.ReadState(containerID)
1414
if err != nil {
15-
return fmt.Errorf("failed to read state 3: %w", err)
15+
return fmt.Errorf("failed to read state while kill: %w", err)
1616
}
1717

1818
if state.Pid > 0 {

internal/runtime/start.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ import (
1212
func Start(containerID string) error {
1313
state, err := oci.ReadState(containerID)
1414
if err != nil {
15-
return fmt.Errorf("failed to read state 4: %w", err)
15+
return fmt.Errorf("failed to read state while start: %w", err)
1616
}
1717
firmwarePath := state.Annotations[oci.StateFirmwarePath]
1818
if firmwarePath == "" {

internal/runtime/state.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ import (
1010
func State(containerID string) (*specs.State, error) {
1111
state, err := oci.ReadState(containerID)
1212
if err != nil {
13-
return nil, fmt.Errorf("failed to read state 5: %w", err)
13+
return nil, fmt.Errorf("failed to read state while getting state: %w", err)
1414
}
1515
return state, nil
1616
}

0 commit comments

Comments
 (0)