Skip to content
This repository has been archived by the owner on Nov 8, 2022. It is now read-only.

Commit

Permalink
Improved error messaging for plugin unload
Browse files Browse the repository at this point in the history
Changed the error message to more appropriate one for `plugin swap` when ver < 1
  • Loading branch information
IzabellaRaulin committed Mar 27, 2017
1 parent d1aac41 commit 65c9ee1
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions cmd/snaptel/plugin.go
Original file line number Diff line number Diff line change
Expand Up @@ -66,19 +66,24 @@ func loadPlugin(ctx *cli.Context) error {
func unloadPlugin(ctx *cli.Context) error {
pType := ctx.Args().Get(0)
pName := ctx.Args().Get(1)
pVer, err := strconv.Atoi(ctx.Args().Get(2))
pVerStr := ctx.Args().Get(2)

if pType == "" {
return newUsageError("Must provide plugin type", ctx)
}
if pName == "" {
return newUsageError("Must provide plugin name", ctx)
}
if pVerStr == "" {
return newUsageError("Must provide plugin version", ctx)
}

pVer, err := strconv.Atoi(pVerStr)
if err != nil {
return newUsageError("Can't convert version string to integer", ctx)
}
if pVer < 1 {
return newUsageError("Must provide plugin version", ctx)
return newUsageError("Plugin version must be greater than zero", ctx)
}

r := pClient.UnloadPlugin(pType, pName, pVer)
Expand Down Expand Up @@ -139,7 +144,7 @@ func swapPlugins(ctx *cli.Context) error {
return newUsageError("Must provide plugin name", ctx)
}
if pVer < 1 {
return newUsageError("Must provide plugin version", ctx)
return newUsageError("Plugin version must be greater than zero", ctx)
}

r := pClient.SwapPlugin(paths, pType, pName, pVer)
Expand Down

0 comments on commit 65c9ee1

Please sign in to comment.