Skip to content

Commit

Permalink
cmd/import: improve error message
Browse files Browse the repository at this point in the history
- Print app.Run() error
  • Loading branch information
unknwon committed Oct 26, 2019
1 parent 762e116 commit 1cfdd12
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 7 deletions.
7 changes: 5 additions & 2 deletions gogs.go
Expand Up @@ -11,12 +11,13 @@ import (
"os"

"github.com/urfave/cli"
log "gopkg.in/clog.v1"

"gogs.io/gogs/internal/cmd"
"gogs.io/gogs/internal/setting"
)

const Version = "0.11.96.1024"
const Version = "0.11.96.1026"

func init() {
setting.AppVer = Version
Expand All @@ -37,5 +38,7 @@ func main() {
cmd.Backup,
cmd.Restore,
}
app.Run(os.Args)
if err := app.Run(os.Args); err != nil {
log.Fatal(2, "Failed to run: %v", err)
}
}
9 changes: 5 additions & 4 deletions internal/cmd/import.go
Expand Up @@ -7,6 +7,7 @@ package cmd
import (
"bufio"
"bytes"
"errors"
"fmt"
"os"
"path/filepath"
Expand Down Expand Up @@ -43,14 +44,14 @@ without manually hacking the data files`,

func runImportLocale(c *cli.Context) error {
if !c.IsSet("source") {
return fmt.Errorf("Source directory is not specified")
return errors.New("source directory is not specified")
} else if !c.IsSet("target") {
return fmt.Errorf("Target directory is not specified")
return errors.New("target directory is not specified")
}
if !com.IsDir(c.String("source")) {
return fmt.Errorf("Source directory does not exist or is not a directory")
return fmt.Errorf("source directory %q does not exist or is not a directory", c.String("source"))
} else if !com.IsDir(c.String("target")) {
return fmt.Errorf("Target directory does not exist or is not a directory")
return fmt.Errorf("target directory %q does not exist or is not a directory", c.String("target"))
}

if c.IsSet("config") {
Expand Down
2 changes: 1 addition & 1 deletion templates/.VERSION
@@ -1 +1 @@
0.11.96.1024
0.11.96.1026

0 comments on commit 1cfdd12

Please sign in to comment.