We cannot always depend on ERRORLEVEL, because many times external programs or batch scripts do not return exit codes.
In that case we can use generic checks for failures like this:
IF EXIST %outfile% (DEL /F %outfile%)
CALL some_script.bat -o %outfile%
IF NOT EXIST %outfile% (ECHO ERROR & EXIT /b)
And if the program outputs something to console, we can check it also.
some_program.exe 2>&1 | FIND "error message here" && (ECHO ERROR & EXIT /b)
some_program.exe 2>&1 | FIND "Done processing." || (ECHO ERROR & EXIT /b)