mirror of
https://github.com/Threnklyn/jira.git
synced 2026-05-18 20:23:28 +02:00
use jiracli.Error object to disambiguate between kingpin errors and cli errors
This commit is contained in:
+10
-5
@@ -329,11 +329,16 @@ func main() {
|
||||
}
|
||||
}
|
||||
if _, err := app.Parse(os.Args[1:]); err != nil {
|
||||
ctx, _ := app.ParseContext(os.Args[1:])
|
||||
if ctx != nil {
|
||||
app.UsageForContext(ctx)
|
||||
if _, ok := err.(*jiracli.Error); ok {
|
||||
log.Errorf("%s", err)
|
||||
panic(jiracli.Exit{Code: 1})
|
||||
} else {
|
||||
ctx, _ := app.ParseContext(os.Args[1:])
|
||||
if ctx != nil {
|
||||
app.UsageForContext(ctx)
|
||||
}
|
||||
log.Errorf("Invalid Usage: %s", err)
|
||||
panic(jiracli.Exit{Code: 1})
|
||||
}
|
||||
log.Errorf("Invalid Usage: %s", err)
|
||||
panic(jiracli.Exit{Code: 1})
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,13 @@
|
||||
package jiracli
|
||||
|
||||
import "github.com/pkg/errors"
|
||||
|
||||
type Error struct {
|
||||
error
|
||||
}
|
||||
|
||||
func cliError(cause error) error {
|
||||
return &Error{
|
||||
errors.WithStack(cause),
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user