Skip to content

Commit fba9adb

Browse files
committed
fix: wrap errors using %w for proper error propagation
1 parent 987fea4 commit fba9adb

5 files changed

Lines changed: 8 additions & 8 deletions

File tree

.gitignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
/playground_/
2-
/bin
2+
/bin/
33

4+
/test_.txt

cmd/agent/main.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ import (
99

1010
func main() {
1111
if len(os.Args) < 2 {
12-
log.Println("usage: go run main.go <port> !!!") // I should avoid 1-1023 ports
12+
log.Println("usage: go run main.go <port> !!!") // should avoid 1-1023 ports
1313
return
1414
}
1515

internal/execution/runner_docker.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ func RunCommand(command string) (*Result, error) {
2222

2323
cli, err := client.NewClientWithOpts(client.FromEnv, client.WithAPIVersionNegotiation())
2424
if err != nil {
25-
return nil, fmt.Errorf("failed to connect to docker: %v", err)
25+
return nil, fmt.Errorf("failed to connect to docker: %w", err)
2626
}
2727
defer cli.Close()
2828

@@ -54,7 +54,7 @@ func RunCommand(command string) (*Result, error) {
5454
select {
5555
case err := <-errCh:
5656
if err != nil {
57-
return nil, fmt.Errorf("execution error: %v", err)
57+
return nil, fmt.Errorf("execution error: %w", err)
5858
}
5959
case <-statusCh:
6060
case <-waitCtx.Done():
@@ -63,7 +63,7 @@ func RunCommand(command string) (*Result, error) {
6363

6464
out, err := cli.ContainerLogs(ctx, containerID, container.LogsOptions{ShowStdout: true, ShowStderr: true})
6565
if err != nil {
66-
return nil, fmt.Errorf("log retrieval failed: %v", err)
66+
return nil, fmt.Errorf("log retrieval failed: %w", err)
6767
}
6868

6969
var stdout, stderr bytes.Buffer

internal/network/protocol.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,8 @@ type Request struct {
1515
*/
1616
type Response struct {
1717
Status string `json:"status_"`
18-
19-
Message string `json:"message_"` // json name is used during testing calls
18+
Message string `json:"message_"`
19+
// json name is used during testing calls
2020
// Message in GO , message in json
2121
// it's a mapping layer
2222
}

test.txt

Lines changed: 0 additions & 1 deletion
This file was deleted.

0 commit comments

Comments
 (0)