Skip to content

Commit 693cb98

Browse files
committed
handle errors correctly
1 parent 7b2ff84 commit 693cb98

File tree

1 file changed

+23
-15
lines changed

1 file changed

+23
-15
lines changed

pkg/cmd/autostop/autostop.go

Lines changed: 23 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -25,14 +25,17 @@ func NewCmdautostop(t *terminal.Terminal, store autostopStore) *cobra.Command {
2525
Long: long,
2626
Example: example,
2727
RunE: func(cmd *cobra.Command, args []string) error {
28-
return breverrors.WrapAndTrace(
29-
Runautostop(
30-
runAutostopArgs{
31-
t: t,
32-
args: args,
33-
store: store,
34-
},
35-
))
28+
err := Runautostop(
29+
runAutostopArgs{
30+
t: t,
31+
args: args,
32+
store: store,
33+
},
34+
)
35+
if err != nil {
36+
return breverrors.WrapAndTrace(err)
37+
}
38+
return nil
3639
},
3740
}
3841
return cmd
@@ -66,13 +69,18 @@ func Runautostop(args runAutostopArgs) error {
6669
return mo.TupleToResult(args.store.AutoStopWorkspace(env.ID))
6770
},
6871
)
69-
return breverrors.WrapAndTrace(
70-
lo.Reduce(
71-
asResults,
72-
func(acc error, res mo.Result[*entity.Workspace], _ int) error {
72+
err = lo.Reduce(
73+
asResults,
74+
func(acc error, res mo.Result[*entity.Workspace], _ int) error {
75+
if res.IsError() {
7376
return multierror.Append(acc, res.Error())
74-
},
75-
nil,
76-
),
77+
}
78+
return acc
79+
},
80+
nil,
7781
)
82+
if err != nil {
83+
return breverrors.WrapAndTrace(err)
84+
}
85+
return nil
7886
}

0 commit comments

Comments
 (0)