improved session error handling

fixes #1946