In a Windows batch file, I am taking an optional parameter that allows the caller to jump to the middle of the batch file and resume from there.
For example:
if [%1] neq [] (
echo Starting from step %1
goto %1
if %errorlevel% neq 0 goto error
)
:step1
:step2
...
goto end
:error
echo Error handler
...
:end
If the supplied parameter is not a valid label, the batch file immediately exits with the error The system cannot find the batch label specified.
Is there any way for me to handle this error and either execute my error handler block, or resume execution of the entire batch file, as if no parameter had been supplied?