Proper error handling in sendMsg()