Skip to content

Commit

Permalink
log error instead of returning it
Browse files Browse the repository at this point in the history
  • Loading branch information
radeksimko committed May 27, 2022
1 parent 48c0cc2 commit eee550a
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 10 deletions.
7 changes: 6 additions & 1 deletion internal/langserver/handlers/command/handler.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,12 @@
package command

import "github.com/hashicorp/terraform-ls/internal/state"
import (
"log"

"github.com/hashicorp/terraform-ls/internal/state"
)

type CmdHandler struct {
StateStore *state.StateStore
Logger *log.Logger
}
13 changes: 4 additions & 9 deletions internal/langserver/handlers/command/module_calls.go
Original file line number Diff line number Diff line change
Expand Up @@ -57,17 +57,12 @@ func (h *CmdHandler) ModuleCallsHandler(ctx context.Context, args cmd.CommandArg
return response, nil
}

modCalls, err := parseModuleRecords(ctx, found.ModManifest.Records)
if err != nil {
return response, err
}

response.ModuleCalls = modCalls
response.ModuleCalls = h.parseModuleRecords(ctx, found.ModManifest.Records)

return response, nil
}

func parseModuleRecords(ctx context.Context, records []datadir.ModuleRecord) ([]moduleCall, error) {
func (h *CmdHandler) parseModuleRecords(ctx context.Context, records []datadir.ModuleRecord) []moduleCall {
// sort all records by key so that dependent modules are found
// after primary modules
sort.SliceStable(records, func(i, j int) bool {
Expand Down Expand Up @@ -96,7 +91,7 @@ func parseModuleRecords(ctx context.Context, records []datadir.ModuleRecord) ([]

docsLink, err := getModuleDocumentationLink(ctx, manifest)
if err != nil {
return nil, err
h.Logger.Printf("failed to get module docs link: %s", err)
}

// build what we know
Expand Down Expand Up @@ -131,7 +126,7 @@ func parseModuleRecords(ctx context.Context, records []datadir.ModuleRecord) ([]
return list[i].Name < list[j].Name
})

return list, nil
return list
}

func getModuleDocumentationLink(ctx context.Context, record datadir.ModuleRecord) (string, error) {
Expand Down
1 change: 1 addition & 0 deletions internal/langserver/handlers/execute_command.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import (
func cmdHandlers(svc *service) cmd.Handlers {
cmdHandler := &command.CmdHandler{
StateStore: svc.stateStore,
Logger: svc.logger,
}
return cmd.Handlers{
cmd.Name("rootmodules"): removedHandler("use module.callers instead"),
Expand Down

0 comments on commit eee550a

Please sign in to comment.