Skip to content

Commit

Permalink
prettify error messages a bit
Browse files Browse the repository at this point in the history
  • Loading branch information
iximiuz committed Sep 4, 2024
1 parent 2994dd9 commit 35fe44d
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 7 deletions.
12 changes: 6 additions & 6 deletions cmd/challenge/start.go
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,7 @@ func runStartChallenge(ctx context.Context, cli labcli.CLI, opts *startOptions)
User: opts.user,
IDE: true,
}); err != nil {
cli.PrintErr("Error running IDE session: %v", err)
cli.PrintErr("Error running IDE session: %v\n", err)
}
}()
}
Expand Down Expand Up @@ -263,14 +263,14 @@ func runStartChallenge(ctx context.Context, cli labcli.CLI, opts *startOptions)
cli.PrintAux("\r\n\r\nStopping the playground...\r\n")

if chal, err := cli.Client().StopChallenge(ctx, chal.Name); err != nil {
cli.PrintErr("Error stopping the challenge: %v", err)
cli.PrintErr("Error stopping the challenge: %v\n", err)
} else if chal.Play == nil || !chal.Play.Active {
cli.PrintAux("Playground stopped.\r\n")
}
}

case EventWSConnFailed:
return fmt.Errorf("play connection WebSocket closed unexpectedly")
return fmt.Errorf("play connection failed")

case EventSSHConnEnded:
cli.PrintAux("\r\n")
Expand Down Expand Up @@ -334,18 +334,18 @@ func (p *PlayConn) Start() error {
return
}
if websocket.IsUnexpectedCloseError(err) {
p.cli.PrintErr("Play connection WebSocket closed unexpectedly: %v", err)
p.cli.PrintErr("Play connection WebSocket closed unexpectedly: %v\n", err)
p.errCh <- err
return
}

p.cli.PrintErr("Error reading play connection message: %v", err)
p.cli.PrintErr("Error reading play connection message: %v\n", err)
continue
}

var msg PlayConnMessage
if err := json.Unmarshal(message, &msg); err != nil {
p.cli.PrintErr("Error decoding play connection message: %v", err)
p.cli.PrintErr("Error decoding play connection message: %v\n", err)
continue
}

Expand Down
4 changes: 3 additions & 1 deletion cmd/ssh/ssh.go
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,9 @@ func StartSSHSession(
return

case err := <-errCh:
slog.Debug("Tunnel borked", "error", err.Error())
if err != nil {
slog.Debug("Tunnel borked", "error", err.Error())
}
}
}
}()
Expand Down

0 comments on commit 35fe44d

Please sign in to comment.