Add error handling in chat