@@ -60,7 +60,7 @@ func (r *RootCmd) switchOrganization() *clibase.Cmd {
60
60
conf := r .createConfig ()
61
61
orgs ,err := client .OrganizationsByUser (inv .Context (),codersdk .Me )
62
62
if err != nil {
63
- return fmt .Errorf ("failed to get organizations: %w" ,err )
63
+ return xerrors .Errorf ("failed to get organizations: %w" ,err )
64
64
}
65
65
// Keep the list of orgs sorted
66
66
slices .SortFunc (orgs ,func (a ,b codersdk.Organization )int {
@@ -84,7 +84,7 @@ func (r *RootCmd) switchOrganization() *clibase.Cmd {
84
84
if switchToOrg == "" {
85
85
err := conf .Organization ().Delete ()
86
86
if err != nil && ! errors .Is (err ,os .ErrNotExist ) {
87
- return fmt .Errorf ("failed to unset organization: %w" ,err )
87
+ return xerrors .Errorf ("failed to unset organization: %w" ,err )
88
88
}
89
89
_ ,_ = fmt .Fprintf (inv .Stdout ,"Organization unset\n " )
90
90
}else {
@@ -107,7 +107,7 @@ func (r *RootCmd) switchOrganization() *clibase.Cmd {
107
107
// Always write the uuid to the config file. Names can change.
108
108
err := conf .Organization ().Write (orgs [index ].ID .String ())
109
109
if err != nil {
110
- return fmt .Errorf ("failed to write organization to config file: %w" ,err )
110
+ return xerrors .Errorf ("failed to write organization to config file: %w" ,err )
111
111
}
112
112
}
113
113
@@ -123,7 +123,7 @@ func (r *RootCmd) switchOrganization() *clibase.Cmd {
123
123
}
124
124
return sdkError
125
125
}
126
- return fmt .Errorf ("failed to get current organization: %w" ,err )
126
+ return xerrors .Errorf ("failed to get current organization: %w" ,err )
127
127
}
128
128
129
129
_ ,_ = fmt .Fprintf (inv .Stdout ,"Current organization context set to %s (%s)\n " ,current .Name ,current .ID .String ())
@@ -213,7 +213,7 @@ func (r *RootCmd) currentOrganization() *clibase.Cmd {
213
213
typed ,ok := data .([]codersdk.Organization )
214
214
if ! ok {
215
215
// This should never happen
216
- return "" ,fmt .Errorf ("expected []Organization, got %T" ,data )
216
+ return "" ,xerrors .Errorf ("expected []Organization, got %T" ,data )
217
217
}
218
218
return stringFormat (typed )
219
219
}),
@@ -250,7 +250,7 @@ func (r *RootCmd) currentOrganization() *clibase.Cmd {
250
250
case "current" :
251
251
stringFormat = func (orgs []codersdk.Organization ) (string ,error ) {
252
252
if len (orgs )!= 1 {
253
- return "" ,fmt .Errorf ("expected 1 organization, got %d" ,len (orgs ))
253
+ return "" ,xerrors .Errorf ("expected 1 organization, got %d" ,len (orgs ))
254
254
}
255
255
return fmt .Sprintf ("Current CLI Organization: %s (%s)\n " ,orgs [0 ].Name ,orgs [0 ].ID .String ()),nil
256
256
}
@@ -275,7 +275,7 @@ func (r *RootCmd) currentOrganization() *clibase.Cmd {
275
275
default :
276
276
stringFormat = func (orgs []codersdk.Organization ) (string ,error ) {
277
277
if len (orgs )!= 1 {
278
- return "" ,fmt .Errorf ("expected 1 organization, got %d" ,len (orgs ))
278
+ return "" ,xerrors .Errorf ("expected 1 organization, got %d" ,len (orgs ))
279
279
}
280
280
return fmt .Sprintf ("Organization: %s (%s)\n " ,orgs [0 ].Name ,orgs [0 ].ID .String ()),nil
281
281
}