dry error messages
This commit is contained in:
parent
e67e05f617
commit
6023f370c1
18
app.go
18
app.go
@ -91,26 +91,26 @@ func (a *App) Run(arguments []string) error {
|
|||||||
|
|
||||||
context := NewContext(a, set, set)
|
context := NewContext(a, set, set)
|
||||||
|
|
||||||
if nerr != nil {
|
// Define here so it closes over the above variables
|
||||||
fmt.Println(nerr)
|
showErrAndHelp := func(err error) {
|
||||||
|
fmt.Println(err)
|
||||||
fmt.Println("")
|
fmt.Println("")
|
||||||
ShowAppHelp(context)
|
ShowAppHelp(context)
|
||||||
fmt.Println("")
|
fmt.Println("")
|
||||||
|
}
|
||||||
|
|
||||||
|
if nerr != nil {
|
||||||
|
showErrAndHelp(nerr)
|
||||||
return nerr
|
return nerr
|
||||||
}
|
}
|
||||||
|
|
||||||
if cerr != nil {
|
if cerr != nil {
|
||||||
fmt.Println(cerr)
|
showErrAndHelp(cerr)
|
||||||
fmt.Println("")
|
|
||||||
ShowAppHelp(context)
|
|
||||||
fmt.Println("")
|
|
||||||
return cerr
|
return cerr
|
||||||
}
|
}
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
fmt.Printf("Incorrect Usage.\n\n")
|
showErrAndHelp(fmt.Errorf("Incorrect Usage."))
|
||||||
ShowAppHelp(context)
|
|
||||||
fmt.Println("")
|
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user