Skip to content

Commit

Permalink
Make the ui.Error calls consistent
Browse files Browse the repository at this point in the history
  • Loading branch information
paultyng committed May 21, 2020
1 parent 5bf6d44 commit 805b214
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 9 deletions.
8 changes: 4 additions & 4 deletions commands/completion_command.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ func (c *CompletionCommand) flags() *flag.FlagSet {
func (c *CompletionCommand) Run(args []string) int {
f := c.flags()
if err := f.Parse(args); err != nil {
c.Ui.Error(fmt.Sprintf("Error parsing command-line flags: %s\n", err.Error()))
c.Ui.Error(fmt.Sprintf("Error parsing command-line flags: %s", err))
return 1
}

Expand All @@ -59,17 +59,17 @@ func (c *CompletionCommand) Run(args []string) int {
lspUri := ilsp.FileHandlerFromPath(path).DocumentURI()
parts := strings.Split(c.atPos, ":")
if len(parts) != 2 {
c.Ui.Error(fmt.Sprintf("Error parsing at-pos argument: %q (expected line:col format)\n", c.atPos))
c.Ui.Error(fmt.Sprintf("Error parsing at-pos argument: %q (expected line:col format)", c.atPos))
return 1
}
line, err := strconv.Atoi(parts[0])
if err != nil {
c.Ui.Error(fmt.Sprintf("Error parsing line: %s (expected number)\n", err))
c.Ui.Error(fmt.Sprintf("Error parsing line: %s (expected number)", err))
return 1
}
col, err := strconv.Atoi(parts[1])
if err != nil {
c.Ui.Error(fmt.Sprintf("Error parsing column: %s (expected number)\n", err))
c.Ui.Error(fmt.Sprintf("Error parsing column: %s (expected number)", err))
return 1
}
lspPos := lsp.Position{Line: line, Character: col}
Expand Down
10 changes: 5 additions & 5 deletions commands/serve_command.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,15 +46,15 @@ func (c *ServeCommand) flags() *flag.FlagSet {
func (c *ServeCommand) Run(args []string) int {
f := c.flags()
if err := f.Parse(args); err != nil {
c.Ui.Error(fmt.Sprintf("Error parsing command-line flags: %s\n", err.Error()))
c.Ui.Error(fmt.Sprintf("Error parsing command-line flags: %s", err))
return 1
}

var logger *log.Logger
if c.logFilePath != "" {
fl, err := logging.NewFileLogger(c.logFilePath)
if err != nil {
c.Ui.Error(fmt.Sprintf("Failed to setup file logging: %s\n", err.Error()))
c.Ui.Error(fmt.Sprintf("Failed to setup file logging: %s", err))
return 1
}
defer fl.Close()
Expand All @@ -71,7 +71,7 @@ func (c *ServeCommand) Run(args []string) int {
if c.tfExecLogPath != "" {
err := logging.ValidateExecLogPath(c.tfExecLogPath)
if err != nil {
c.Ui.Error(fmt.Sprintf("Failed to setup logging for Terraform: %s\n", err.Error()))
c.Ui.Error(fmt.Sprintf("Failed to setup logging for Terraform: %s", err))
return 1
}
ctx = lsctx.WithTerraformExecLogPath(c.tfExecLogPath, ctx)
Expand Down Expand Up @@ -110,15 +110,15 @@ func (c *ServeCommand) Run(args []string) int {
if c.port != 0 {
err := srv.StartTCP(fmt.Sprintf("localhost:%d", c.port))
if err != nil {
c.Ui.Error(fmt.Sprintf("Failed to start TCP server: %s\n", err))
c.Ui.Error(fmt.Sprintf("Failed to start TCP server: %s", err))
return 1
}
return 0
}

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

Expand Down

0 comments on commit 805b214

Please sign in to comment.