The usage of $ZERROR is discouraged. You should use a TRY/CATCH block instead.

See