The condition error_message is true if the incoming message is a mail delivery error message (bounce message). Putting the command
if error_message then finish endif
at the head of your filter file is a useful insurance against things going wrong in such a way that you cannot receive delivery error reports, and is highly recommended. Note that error_message is a condition, not an expansion variable, and therefore is not preceded by $.