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

Commit efc1f6e

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

File tree

3 files changed

+16
-3
lines changed

3 files changed

+16
-3
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/envs.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,7 @@ coder envs --user charlie@coder.com ls -o json \
111111
}
112112

113113
if err = egroup.Wait(); err != nil {
114-
return xerrors.Errorf("some stop operations failed: %w", err)
114+
return xerrors.Errorf("some stop operations failed")
115115
}
116116
return nil
117117
},

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)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy