Thanks to visit codestin.com
Credit goes to github.com

Skip to content
This repository was archived by the owner on Aug 30, 2024. It is now read-only.

Commit 155fa2b

Browse files
committed
Improve environment not found error message
1 parent 3bee6d0 commit 155fa2b

File tree

2 files changed

+15
-2
lines changed

2 files changed

+15
-2
lines changed

internal/cmd/ceapi.go

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ package cmd
22

33
import (
44
"context"
5+
"fmt"
56

67
"cdr.dev/coder-cli/coder-sdk"
78
"golang.org/x/xerrors"
@@ -72,5 +73,17 @@ func findEnv(ctx context.Context, client *coder.Client, envName, userEmail strin
7273
found = append(found, env.Name)
7374
}
7475

75-
return nil, coder.ErrNotFound
76+
return nil, notFoundButDidFind{
77+
needle: envName,
78+
haystack: found,
79+
}
80+
}
81+
82+
type notFoundButDidFind struct {
83+
needle string
84+
haystack []string
85+
}
86+
87+
func (n notFoundButDidFind) Error() string {
88+
return fmt.Sprintf("\"%s\" not found in %q: %v", n.needle, n.haystack, coder.ErrNotFound)
7689
}

internal/cmd/shell.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -153,7 +153,7 @@ func runCommand(ctx context.Context, envName, command string, args []string) err
153153
if err != nil {
154154
var closeErr websocket.CloseError
155155
if xerrors.As(err, &closeErr) {
156-
return xerrors.Errorf("network error, is %q online? (%w)", envName, err)
156+
return xerrors.Errorf("network error, is %q online?", envName)
157157
}
158158
return xerrors.Errorf("start remote command: %w", err)
159159
}

0 commit comments

Comments
 (0)