Skip to content

Commit 57ebf30

Browse files
fix: wrap errors
1 parent a5b412b commit 57ebf30

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

coderd/agentapi/scripts.go

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import (
44
"context"
55

66
"github.com/google/uuid"
7+
"golang.org/x/xerrors"
78

89
agentproto "github.com/coder/coder/v2/agent/proto"
910
"github.com/coder/coder/v2/coderd/database"
@@ -19,12 +20,12 @@ func (s *ScriptsAPI) ScriptCompleted(ctx context.Context, req *agentproto.Worksp
1920

2021
agent, err := s.Database.GetWorkspaceAgentByID(ctx, s.AgentID)
2122
if err != nil {
22-
return nil, err
23+
return nil, xerrors.Errorf("get workspace agent by id in database: %w", err)
2324
}
2425

2526
resource, err := s.Database.GetWorkspaceResourceByID(ctx, agent.ResourceID)
2627
if err != nil {
27-
return nil, err
28+
return nil, xerrors.Errorf("get workspace resource by id in database: %w", err)
2829
}
2930

3031
_, err = s.Database.InsertWorkspaceAgentScriptTimings(ctx, database.InsertWorkspaceAgentScriptTimingsParams{
@@ -35,7 +36,7 @@ func (s *ScriptsAPI) ScriptCompleted(ctx context.Context, req *agentproto.Worksp
3536
ExitCode: req.Timing.ExitCode,
3637
})
3738
if err != nil {
38-
return nil, err
39+
return nil, xerrors.Errorf("insert workspace agent script timings into database: %w", err)
3940
}
4041

4142
return res, nil

0 commit comments

Comments
 (0)