From 7b1536e6b23761e460533e5702680c56adb2830e Mon Sep 17 00:00:00 2001 From: zhangyangyu Date: Mon, 30 Sep 2024 23:13:52 +0800 Subject: [PATCH] slightly fix ui/shell.go --- internal/util/shell.go | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/internal/util/shell.go b/internal/util/shell.go index 388ee137..5f484f90 100644 --- a/internal/util/shell.go +++ b/internal/util/shell.go @@ -17,6 +17,7 @@ package util import ( "context" "crypto/tls" + "errors" "fmt" "io" "os" @@ -84,7 +85,7 @@ func generateDsnWithPassword(clusterType string, userName string, host string, p } else if clusterType == DEDICATED { dsn = fmt.Sprintf("tidb://%s:%s@%s:%s?tls=skip-verify", userName, pass, host, port) } else { - return "", fmt.Errorf("unsupproted cluster type: %s", clusterType) + return "", fmt.Errorf("unsupported cluster type: %s", clusterType) } return dsn, nil } @@ -103,13 +104,13 @@ func generateDsnWithoutPassword(clusterType string, userName string, host string } else if clusterType == DEDICATED { dsn = fmt.Sprintf("tidb://%s@%s:%s?tls=skip-verify", userName, host, port) } else { - return "", fmt.Errorf("unsupproted cluster type: %s", clusterType) + return "", fmt.Errorf("unsupported cluster type: %s", clusterType) } // Prompt for password dsn, err := h.Password(dsn) - if err != nil { - return "", err + if err != nil && errors.Is(err, rline.ErrInterrupt) { + return "", InterruptError } - return dsn, nil + return dsn, err }