Neither a departure from the form or mode prescribed by this Code in respect to any pleading or proceeding, nor an error or mistake therein, renders it invalid, unless it has actually prejudiced the defendant, or tended to his prejudice, in respect to a substantial right.