Error handling for sendMessage