Skip to content
This repository has been archived by the owner on Jan 14, 2020. It is now read-only.

Commit

Permalink
added error handling for plugins
Browse files Browse the repository at this point in the history
  • Loading branch information
ojkelly committed Jul 13, 2018
1 parent 9104ca2 commit ac65ec5
Show file tree
Hide file tree
Showing 2 changed files with 46 additions and 4 deletions.
48 changes: 45 additions & 3 deletions internal/plugins/extract.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,21 @@ func ExtractResourcesFromPlugins(
wrappedParserFunc := func(
name string, data string,
) (kombustionTypes.TemplateObject, error) {
resources, _ := loadResource(parserFunc(name, data))
resources, errs := loadResource(parserFunc(name, data))
for _, err := range errs {
if err != nil {
printer.Error(
err,
fmt.Sprintf(
"\n ├─ Name: %s\n ├─ Plugin: %s\n └─ Type: %s",
name,
plugin.Config.Name,
pluginKey,
),
"",
)
}
}
// TODO: print errs here as we know what plugin they came from
return resources, nil
}
Expand Down Expand Up @@ -61,7 +75,21 @@ func ExtractMappingsFromPlugins(
wrappedParserFunc := func(
name string, data string,
) (kombustionTypes.TemplateObject, error) {
mapping, _ := loadMapping(parserFunc(name, data))
mapping, errs := loadMapping(parserFunc(name, data))
for _, err := range errs {
if err != nil {
printer.Error(
err,
fmt.Sprintf(
"\n ├─ Name: %s\n ├─ Plugin: %s\n └─ Type: %s",
name,
plugin.Config.Name,
pluginKey,
),
"",
)
}
}
return mapping, nil
}
(*mappings)[pluginKey] = wrappedParserFunc
Expand Down Expand Up @@ -95,7 +123,21 @@ func ExtractOutputsFromPlugins(
wrappedParserFunc := func(
name string, data string,
) (kombustionTypes.TemplateObject, error) {
outputs, _ := loadOutput(parserFunc(name, data))
outputs, errs := loadOutput(parserFunc(name, data))
for _, err := range errs {
if err != nil {
printer.Error(
err,
fmt.Sprintf(
"\n ├─ Name: %s\n ├─ Plugin: %s\n └─ Type: %s",
name,
plugin.Config.Name,
pluginKey,
),
"",
)
}
}
return outputs, nil
}
(*outputs)[pluginKey] = wrappedParserFunc
Expand Down
2 changes: 1 addition & 1 deletion internal/plugins/install.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ func InstallPlugins() error {

// TODO: This error message could be more helpful
printer.Fatal(
fmt.Errorf("Failed installing plugins."),
fmt.Errorf("failed installing plugins"),
"Error installing plugins",
"",
)
Expand Down

0 comments on commit ac65ec5

Please sign in to comment.