db_lmdb: factor all the log+throw code paths