get threads from database, improve error reporting