How ERR trap works?

# Sample script that shows how ERR signal works, when a command returns a non-zero status it triggers to calls to print the message in double quotes.

trap ‘print “You gave me non-integer. Try again”‘ ERR
typeset -i number
while true
do
print -n “Enter an integer: ”
read number 2> /dev/null
if [ $? -eq 0 ]; then
break
fi
done

# reset trap else the grep command below would also generate the error message
trap – ERR
grep “blahblah” /etc/passwd > /dev/null 2>&1
echo “Number entered: $number