lib: catch error from closed db in n_m_get_message_id