zot / microfts

Small and fast FTS (full text search)
MIT License
32 stars 3 forks source link

missing input files generate a panic #16

Open sje30 opened 2 years ago

sje30 commented 2 years ago

Hi, If /tmp/tst is missing (I had created /tmp/test by mistake, following your README), I get a panic. The panic message explains the error, but then it is followed by a long backtrace (truncated below).

./microfts input -file /tmp/bubba /tmp/tst
panic: Error: stat /tmp/tst: no such file or directory, args: [/tmp/bubba /tmp/tst]

goroutine 1 [running]:
main.check(0x59fe60, 0xc00007a720)
        /home/bill/work/microfts/fulltext.go:205 +0x150
main.(*lmdbConfigStruct).openInputFile(0x686980, 0x7fff9d4de550, 0x8, 0xc00013baa0, 0x4e740c, 0x7f9cec003ffb, 0x4)
        /home/bill/work/microfts/fts-lmdb.go:535 +0x79
main.(*lmdbConfigStruct).indexLines(0x686980, 0x7fff9d4de550, 0x8)
        /home/bill/work/microfts/fts-lmdb.go:579 +0x5d
main.(*lmdbConfigStruct).index(0x686980, 0x7fff9d4de550, 0x8)
        /home/bill/work/microfts/fts-lmdb.go:529 +0x6f
main.cmdInput.func1()
zot commented 2 years ago

Makes sense. The important thing is that is returns a non-zero result (which it does) but I could have in a friendlier error message...