Due to a missing new line, the error code returned by the function is taking as another argument.
call :function if errorlevel 1 exit /b 1
The code should be
call :function if errorlevel 1 exit /b 1
Changed to use a simple '||' logic
call :function || exit /b 1