Improve logging and errors
This commit is contained in:
parent
64d6b05514
commit
04fa3afc67
9
file.go
9
file.go
|
@ -34,7 +34,6 @@ import (
|
|||
"time"
|
||||
|
||||
"github.com/blevesearch/bleve"
|
||||
"github.com/davecgh/go-spew/spew"
|
||||
"github.com/sergi/go-diff/diffmatchpatch"
|
||||
)
|
||||
|
||||
|
@ -184,6 +183,7 @@ func (fp *FilePages) Get(name string) Page {
|
|||
|
||||
page, err := fp.oldPagesBackend(name)
|
||||
if err != nil {
|
||||
log.Println("Deprecated:", err)
|
||||
return fp.blocksBackendGet(name, BlockResponse{ParentID: "root", PageID: name}, to)
|
||||
}
|
||||
|
||||
|
@ -241,25 +241,23 @@ func (fp *FilePages) oldPagesBackend(title string) (Page, error) {
|
|||
|
||||
f, err := os.Open(filepath.Join(fp.dirname, name))
|
||||
if err != nil {
|
||||
log.Printf("while opening file in oldPagesBackend: %s", err)
|
||||
return Page{
|
||||
Title: title,
|
||||
Name: name,
|
||||
Content: "",
|
||||
Refs: refs,
|
||||
}, err
|
||||
}, fmt.Errorf("in old pages backend: %w", err)
|
||||
}
|
||||
|
||||
defer f.Close()
|
||||
body, err := ioutil.ReadAll(f)
|
||||
if err != nil {
|
||||
log.Printf("while reading file in oldPagesBackend: %s", err)
|
||||
return Page{
|
||||
Name: name,
|
||||
Title: title,
|
||||
Content: "",
|
||||
Refs: refs,
|
||||
}, err
|
||||
}, fmt.Errorf("while reading %q in old pages backend: %w", name, err)
|
||||
}
|
||||
|
||||
return Page{
|
||||
|
@ -289,7 +287,6 @@ func (fp *FilePages) save(msg saveMessage) error {
|
|||
page.Name = p
|
||||
page.Title = p
|
||||
}
|
||||
spew.Dump(page)
|
||||
|
||||
sw.Start("create blocks")
|
||||
err := saveBlocksFromPage(fp.dirname, page)
|
||||
|
|
Loading…
Reference in New Issue
Block a user