Add error handling to batch script (#10007)
This commit is contained in:
committed by
GitHub
parent
5be2fb0b8a
commit
edb61cb2ea
@@ -80,9 +80,9 @@ GOTO :after_subroutine
|
||||
:do_sdk_update_and_snapshot
|
||||
ECHO Checking Dart SDK version...
|
||||
CALL PowerShell.exe -ExecutionPolicy Bypass -Command "& '%FLUTTER_ROOT%/bin/internal/update_dart_sdk.ps1'"
|
||||
SET exit_code=%ERRORLEVEL%
|
||||
IF %exit_code% NEQ 0 (
|
||||
ECHO Error: Unable to update Dart SDK. Retrying... Press Ctrl+C to abort.
|
||||
IF "%ERRORLEVEL%" NEQ "0" (
|
||||
ECHO Error: Unable to update Dart SDK. Retrying...
|
||||
timeout /t 5 /nobreak
|
||||
GOTO :do_sdk_update_and_snapshot
|
||||
)
|
||||
|
||||
@@ -93,22 +93,35 @@ GOTO :after_subroutine
|
||||
|
||||
REM Makes changes to PUB_ENVIRONMENT only visible to commands within SETLOCAL/ENDLOCAL
|
||||
SETLOCAL
|
||||
IF "%TRAVIS%" == "true" GOTO on_bot
|
||||
IF "%BOT%" == "true" GOTO on_bot
|
||||
IF "%CONTINUOUS_INTEGRATION%" == "true" GOTO on_bot
|
||||
IF "%CHROME_HEADLESS%" == "1" GOTO on_bot
|
||||
IF "%APPVEYOR%" == "true" GOTO on_bot
|
||||
IF "%CI%" == "true" GOTO on_bot
|
||||
GOTO not_on_bot
|
||||
:on_bot
|
||||
SET PUB_ENVIRONMENT=%PUB_ENVIRONMENT%:flutter_bot
|
||||
:not_on_bot
|
||||
SET PUB_ENVIRONMENT=%PUB_ENVIRONMENT%:flutter_install
|
||||
CALL "%pub%" upgrade --verbosity=error --no-packages-dir
|
||||
IF "%TRAVIS%" == "true" GOTO on_bot
|
||||
IF "%BOT%" == "true" GOTO on_bot
|
||||
IF "%CONTINUOUS_INTEGRATION%" == "true" GOTO on_bot
|
||||
IF "%CHROME_HEADLESS%" == "1" GOTO on_bot
|
||||
IF "%APPVEYOR%" == "true" GOTO on_bot
|
||||
IF "%CI%" == "true" GOTO on_bot
|
||||
GOTO not_on_bot
|
||||
:on_bot
|
||||
SET PUB_ENVIRONMENT=%PUB_ENVIRONMENT%:flutter_bot
|
||||
:not_on_bot
|
||||
SET PUB_ENVIRONMENT=%PUB_ENVIRONMENT%:flutter_install
|
||||
:retry_pub_upgrade
|
||||
CALL "%pub%" upgrade --verbosity=error --no-packages-dir
|
||||
IF "%ERRORLEVEL%" NEQ "0" (
|
||||
ECHO Error: Unable to 'pub upgrade' flutter tool. Retrying...
|
||||
timeout /t 5 /nobreak
|
||||
GOTO :retry_pub_upgrade
|
||||
)
|
||||
ENDLOCAL
|
||||
|
||||
POPD
|
||||
|
||||
:retry_dart_snapshot
|
||||
CALL "%dart%" --snapshot="%snapshot_path%" --packages="%flutter_tools_dir%\.packages" "%script_path%"
|
||||
IF "%ERRORLEVEL%" NEQ "0" (
|
||||
ECHO Error: Unable to create dart snapshot for flutter tool. Retrying...
|
||||
timeout /t 5 /nobreak
|
||||
GOTO :retry_dart_snapshot
|
||||
)
|
||||
>"%stamp_path%" ECHO %revision%
|
||||
|
||||
REM Exit Subroutine
|
||||
@@ -120,8 +133,13 @@ CALL "%dart%" %FLUTTER_TOOL_ARGS% "%snapshot_path%" %*
|
||||
SET exit_code=%ERRORLEVEL%
|
||||
|
||||
REM The VM exits with code 253 if the snapshot version is out-of-date.
|
||||
IF /I "%exit_code%" EQU "253" (
|
||||
IF "%exit_code%" EQU "253" (
|
||||
CALL "%dart%" --snapshot="%snapshot_path%" --packages="%flutter_tools_dir%\.packages" "%script_path%"
|
||||
SET exit_code=%ERRORLEVEL%
|
||||
IF "%exit_code%" EQU "253" (
|
||||
ECHO Error: Unable to create dart snapshot for flutter tool.
|
||||
EXIT /B %exit_code%
|
||||
)
|
||||
CALL "%dart%" %FLUTTER_TOOL_ARGS% "%snapshot_path%" %*
|
||||
SET exit_code=%ERRORLEVEL%
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user