mirror of
https://github.com/Threnklyn/jira.git
synced 2026-05-19 04:33: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 {
|
if _, err := app.Parse(os.Args[1:]); err != nil {
|
||||||
ctx, _ := app.ParseContext(os.Args[1:])
|
if _, ok := err.(*jiracli.Error); ok {
|
||||||
if ctx != nil {
|
log.Errorf("%s", err)
|
||||||
app.UsageForContext(ctx)
|
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