Skip to content

Commit 805b214

Browse files
committed
Make the ui.Error calls consistent
1 parent 5bf6d44 commit 805b214

File tree

2 files changed

+9
-9
lines changed

2 files changed

+9
-9
lines changed

commands/completion_command.go

+4-4
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ func (c *CompletionCommand) flags() *flag.FlagSet {
4040
func (c *CompletionCommand) Run(args []string) int {
4141
f := c.flags()
4242
if err := f.Parse(args); err != nil {
43-
c.Ui.Error(fmt.Sprintf("Error parsing command-line flags: %s\n", err.Error()))
43+
c.Ui.Error(fmt.Sprintf("Error parsing command-line flags: %s", err))
4444
return 1
4545
}
4646

@@ -59,17 +59,17 @@ func (c *CompletionCommand) Run(args []string) int {
5959
lspUri := ilsp.FileHandlerFromPath(path).DocumentURI()
6060
parts := strings.Split(c.atPos, ":")
6161
if len(parts) != 2 {
62-
c.Ui.Error(fmt.Sprintf("Error parsing at-pos argument: %q (expected line:col format)\n", c.atPos))
62+
c.Ui.Error(fmt.Sprintf("Error parsing at-pos argument: %q (expected line:col format)", c.atPos))
6363
return 1
6464
}
6565
line, err := strconv.Atoi(parts[0])
6666
if err != nil {
67-
c.Ui.Error(fmt.Sprintf("Error parsing line: %s (expected number)\n", err))
67+
c.Ui.Error(fmt.Sprintf("Error parsing line: %s (expected number)", err))
6868
return 1
6969
}
7070
col, err := strconv.Atoi(parts[1])
7171
if err != nil {
72-
c.Ui.Error(fmt.Sprintf("Error parsing column: %s (expected number)\n", err))
72+
c.Ui.Error(fmt.Sprintf("Error parsing column: %s (expected number)", err))
7373
return 1
7474
}
7575
lspPos := lsp.Position{Line: line, Character: col}

commands/serve_command.go

+5-5
Original file line numberDiff line numberDiff line change
@@ -46,15 +46,15 @@ func (c *ServeCommand) flags() *flag.FlagSet {
4646
func (c *ServeCommand) Run(args []string) int {
4747
f := c.flags()
4848
if err := f.Parse(args); err != nil {
49-
c.Ui.Error(fmt.Sprintf("Error parsing command-line flags: %s\n", err.Error()))
49+
c.Ui.Error(fmt.Sprintf("Error parsing command-line flags: %s", err))
5050
return 1
5151
}
5252

5353
var logger *log.Logger
5454
if c.logFilePath != "" {
5555
fl, err := logging.NewFileLogger(c.logFilePath)
5656
if err != nil {
57-
c.Ui.Error(fmt.Sprintf("Failed to setup file logging: %s\n", err.Error()))
57+
c.Ui.Error(fmt.Sprintf("Failed to setup file logging: %s", err))
5858
return 1
5959
}
6060
defer fl.Close()
@@ -71,7 +71,7 @@ func (c *ServeCommand) Run(args []string) int {
7171
if c.tfExecLogPath != "" {
7272
err := logging.ValidateExecLogPath(c.tfExecLogPath)
7373
if err != nil {
74-
c.Ui.Error(fmt.Sprintf("Failed to setup logging for Terraform: %s\n", err.Error()))
74+
c.Ui.Error(fmt.Sprintf("Failed to setup logging for Terraform: %s", err))
7575
return 1
7676
}
7777
ctx = lsctx.WithTerraformExecLogPath(c.tfExecLogPath, ctx)
@@ -110,15 +110,15 @@ func (c *ServeCommand) Run(args []string) int {
110110
if c.port != 0 {
111111
err := srv.StartTCP(fmt.Sprintf("localhost:%d", c.port))
112112
if err != nil {
113-
c.Ui.Error(fmt.Sprintf("Failed to start TCP server: %s\n", err))
113+
c.Ui.Error(fmt.Sprintf("Failed to start TCP server: %s", err))
114114
return 1
115115
}
116116
return 0
117117
}
118118

119119
err := srv.StartAndWait(os.Stdin, os.Stdout)
120120
if err != nil {
121-
c.Ui.Error(fmt.Sprintf("Failed to start server: %s\n", err))
121+
c.Ui.Error(fmt.Sprintf("Failed to start server: %s", err))
122122
return 1
123123
}
124124

0 commit comments

Comments
 (0)