Adding error handler case in chat.js