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 d88b1e7

Browse files
committed
refactor: Reduce lines of code
Return general error and env status
1 parent b40af27 commit d88b1e7

File tree

1 file changed

+2
-17
lines changed

1 file changed

+2
-17
lines changed

internal/cmd/shell.go

Lines changed: 2 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -229,25 +229,10 @@ func checkAndRebuildEnvironment(ctx context.Context, client *coder.Client, env *
229229
return err
230230
}
231231

232-
// Get a nice error based on the status
233-
switch env.LatestStat.ContainerStatus {
234-
case coder.EnvironmentOn:
235-
// This is the case we expect, just making it explicit
236-
case coder.EnvironmentOff:
237-
err = fmt.Errorf("environment %q is off and will not come online", env.Name)
238-
case coder.EnvironmentFailed:
239-
err = fmt.Errorf("environment %q has failed to build and will not come online", env.Name)
240-
case coder.EnvironmentCreating:
241-
// This should never happen
242-
err = fmt.Errorf("environment %q did not finish being created", env.Name)
243-
default:
244-
err = fmt.Errorf("environment %q has run into an unknown issue", env.Name)
245-
}
246-
247-
if err != nil {
232+
if env.LatestStat.ContainerStatus != coder.EnvironmentOn {
248233
// This means we had a timeout
249234
return clog.Fatal("the environment rebuild ran into an issue",
250-
err.Error(),
235+
fmt.Sprintf("environment %q rebuild has failed and will not come online", env.Name),
251236
fmt.Sprintf("its current status is %q", env.LatestStat.ContainerStatus),
252237
clog.BlankLine,
253238
// TODO: (@emyrk) can they check these logs from the cli? Isn't this the logs that

0 commit comments

Comments
 (0)