lib/message: catch exception in n_m_get_thread_id