From a08956fa63b2f6f8d1624a730a76acae0ca4f95c Mon Sep 17 00:00:00 2001 From: Charlie Moog Date: Mon, 3 Aug 2020 09:54:07 -0500 Subject: [PATCH] Show network error on unexpected disconnect --- cmd/coder/shell.go | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/cmd/coder/shell.go b/cmd/coder/shell.go index c7b42564..bc1c6ef4 100644 --- a/cmd/coder/shell.go +++ b/cmd/coder/shell.go @@ -126,6 +126,10 @@ func runCommand(ctx context.Context, envName string, command string, args []stri Env: cmdEnv, }) if err != nil { + var closeErr websocket.CloseError + if xerrors.As(err, &closeErr) { + return xerrors.Errorf("network error, is %q online?", envName) + } return err } @@ -157,10 +161,14 @@ func runCommand(ctx context.Context, envName string, command string, args []stri } }() err = process.Wait() - if err != nil && xerrors.Is(err, ctx.Err()) { - return xerrors.Errorf("network error, is %q online?", envName) + if err != nil { + var closeErr websocket.CloseError + if xerrors.Is(err, ctx.Err()) || xerrors.As(err, &closeErr) { + return xerrors.Errorf("network error, is %q online?", envName) + } + return err } - return err + return nil } func heartbeat(ctx context.Context, c *websocket.Conn, interval time.Duration) { 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