Add more descriptive error messages for plugin installation failures

Ref #378
This commit is contained in:
Zachary Yedidia 2016-10-05 18:00:05 -04:00
parent 76a328a062
commit d3d35bd9ff
2 changed files with 6 additions and 6 deletions

View File

@ -92,7 +92,7 @@ func DefaultCommands() map[string]StrCommand {
}
}
// InstallPlugin installs the given plugin by exact name match
// PluginCmd installs, removes, updates, lists, or searches for given plugins
func PluginCmd(args []string) {
if len(args) >= 1 {
switch args[0] {
@ -101,8 +101,8 @@ func PluginCmd(args []string) {
pp := GetAllPluginPackages().Get(plugin)
if pp == nil {
messenger.Error("Unknown plugin \"" + plugin + "\"")
} else if !pp.IsInstallable() {
messenger.Error("Plugin \"" + plugin + "\" can not be installed.")
} else if err := pp.IsInstallable(); err != nil {
messenger.Error("Error installing ", plugin, ": ", err)
} else {
pp.Install()
}

View File

@ -298,13 +298,13 @@ func (pp PluginPackage) Match(text string) bool {
}
// IsInstallable returns true if the package can be installed.
func (pp PluginPackage) IsInstallable() bool {
func (pp PluginPackage) IsInstallable() error {
_, err := GetAllPluginPackages().Resolve(GetInstalledVersions(true), PluginDependencies{
&PluginDependency{
Name: pp.Name,
Range: semver.Range(func(v semver.Version) bool { return true }),
}})
return err == nil
return err
}
// SearchPlugin retrieves a list of all PluginPackages which match the given search text and
@ -320,7 +320,7 @@ pluginLoop:
}
}
if pp.IsInstallable() {
if err := pp.IsInstallable(); err == nil {
plugins = append(plugins, pp)
}
}