error context for nav and ui

This commit is contained in:
Gokcehan 2016-08-17 23:22:11 +03:00
parent f20828285e
commit 70f8c1331d
2 changed files with 11 additions and 9 deletions

6
nav.go
View File

@ -117,7 +117,7 @@ func organizeFiles(fi []os.FileInfo) []os.FileInfo {
func newDir(path string) *Dir {
fi, err := ioutil.ReadDir(path)
if err != nil {
log.Print(err)
log.Printf("reading directory: %s", err)
}
fi = organizeFiles(fi)
@ -131,7 +131,7 @@ func newDir(path string) *Dir {
func (dir *Dir) renew(height int) {
fi, err := ioutil.ReadDir(dir.path)
if err != nil {
log.Print(err)
log.Print("reading directory: %s", err)
}
fi = organizeFiles(fi)
@ -205,7 +205,7 @@ func getDirs(wd string, height int) []*Dir {
func newNav(height int) *Nav {
wd, err := os.Getwd()
if err != nil {
log.Print(err)
log.Printf("getting current directory: %s", err)
}
dirs := getDirs(wd, height)

14
ui.go
View File

@ -307,8 +307,9 @@ func (ui *UI) draw(nav *Nav) {
f, err := os.Stat(path)
if err != nil {
ui.message = err.Error()
log.Print(err)
msg := fmt.Sprintf("getting file information: %s", err)
ui.message = msg
log.Print(msg)
return
}
@ -319,8 +320,9 @@ func (ui *UI) draw(nav *Nav) {
} else if f.Mode().IsRegular() {
file, err := os.Open(path)
if err != nil {
ui.message = err.Error()
log.Print(err)
msg := fmt.Sprintf("opening file: %s", err)
ui.message = msg
log.Print(msg)
}
if err := preview.printr(file); err != nil {
@ -472,14 +474,14 @@ func (ui *UI) pause() {
func (ui *UI) resume() {
if err := termbox.Init(); err != nil {
log.Fatal(err)
log.Fatalf("initializing termbox: %s", err)
}
}
func (ui *UI) sync() {
err := termbox.Sync()
if err != nil {
log.Printf("syncing: %s", err)
log.Printf("syncing termbox: %s", err)
}
termbox.SetCursor(0, 0)
termbox.HideCursor()