diff --git a/boltbrowser.go b/boltbrowser.go index d539beb..36cdc48 100644 --- a/boltbrowser.go +++ b/boltbrowser.go @@ -41,8 +41,8 @@ func main() { currentFilename = databaseFile db, err = bolt.Open(databaseFile, 0600, nil) if err != nil { - fmt.Printf("Error reading file: %q\n", err.Error()) - os.Exit(1) + mainLoop(nil, style) + continue } // First things first, load the database into memory diff --git a/screen_browser.go b/screen_browser.go index 1bb42f2..92cfaa3 100644 --- a/screen_browser.go +++ b/screen_browser.go @@ -454,6 +454,12 @@ func (screen *BrowserScreen) moveCursorDown() bool { func (screen *BrowserScreen) performLayout() {} func (screen *BrowserScreen) drawScreen(style Style) { + if screen.db == nil { + screen.drawHeader(style) + screen.setMessage("Invalid DB. Press 'q' to quit, '?' for help") + screen.drawFooter(style) + return + } if len(screen.db.buckets) == 0 && screen.mode&modeInsertBucket != modeInsertBucket { // Force a bucket insert screen.startInsertItemAtParent(typeBucket)