Commit edb61cb2 authored by Michael Goderbauer's avatar Michael Goderbauer Committed by GitHub

Add error handling to batch script (#10007)

parent 5be2fb0b
...@@ -80,9 +80,9 @@ GOTO :after_subroutine ...@@ -80,9 +80,9 @@ GOTO :after_subroutine
:do_sdk_update_and_snapshot :do_sdk_update_and_snapshot
ECHO Checking Dart SDK version... ECHO Checking Dart SDK version...
CALL PowerShell.exe -ExecutionPolicy Bypass -Command "& '%FLUTTER_ROOT%/bin/internal/update_dart_sdk.ps1'" CALL PowerShell.exe -ExecutionPolicy Bypass -Command "& '%FLUTTER_ROOT%/bin/internal/update_dart_sdk.ps1'"
SET exit_code=%ERRORLEVEL% IF "%ERRORLEVEL%" NEQ "0" (
IF %exit_code% NEQ 0 ( ECHO Error: Unable to update Dart SDK. Retrying...
ECHO Error: Unable to update Dart SDK. Retrying... Press Ctrl+C to abort. timeout /t 5 /nobreak
GOTO :do_sdk_update_and_snapshot GOTO :do_sdk_update_and_snapshot
) )
...@@ -93,22 +93,35 @@ GOTO :after_subroutine ...@@ -93,22 +93,35 @@ GOTO :after_subroutine
REM Makes changes to PUB_ENVIRONMENT only visible to commands within SETLOCAL/ENDLOCAL REM Makes changes to PUB_ENVIRONMENT only visible to commands within SETLOCAL/ENDLOCAL
SETLOCAL SETLOCAL
IF "%TRAVIS%" == "true" GOTO on_bot IF "%TRAVIS%" == "true" GOTO on_bot
IF "%BOT%" == "true" GOTO on_bot IF "%BOT%" == "true" GOTO on_bot
IF "%CONTINUOUS_INTEGRATION%" == "true" GOTO on_bot IF "%CONTINUOUS_INTEGRATION%" == "true" GOTO on_bot
IF "%CHROME_HEADLESS%" == "1" GOTO on_bot IF "%CHROME_HEADLESS%" == "1" GOTO on_bot
IF "%APPVEYOR%" == "true" GOTO on_bot IF "%APPVEYOR%" == "true" GOTO on_bot
IF "%CI%" == "true" GOTO on_bot IF "%CI%" == "true" GOTO on_bot
GOTO not_on_bot GOTO not_on_bot
:on_bot :on_bot
SET PUB_ENVIRONMENT=%PUB_ENVIRONMENT%:flutter_bot SET PUB_ENVIRONMENT=%PUB_ENVIRONMENT%:flutter_bot
:not_on_bot :not_on_bot
SET PUB_ENVIRONMENT=%PUB_ENVIRONMENT%:flutter_install SET PUB_ENVIRONMENT=%PUB_ENVIRONMENT%:flutter_install
CALL "%pub%" upgrade --verbosity=error --no-packages-dir :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 ENDLOCAL
POPD POPD
:retry_dart_snapshot
CALL "%dart%" --snapshot="%snapshot_path%" --packages="%flutter_tools_dir%\.packages" "%script_path%" 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% >"%stamp_path%" ECHO %revision%
REM Exit Subroutine REM Exit Subroutine
...@@ -120,8 +133,13 @@ CALL "%dart%" %FLUTTER_TOOL_ARGS% "%snapshot_path%" %* ...@@ -120,8 +133,13 @@ CALL "%dart%" %FLUTTER_TOOL_ARGS% "%snapshot_path%" %*
SET exit_code=%ERRORLEVEL% SET exit_code=%ERRORLEVEL%
REM The VM exits with code 253 if the snapshot version is out-of-date. 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%" 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%" %* CALL "%dart%" %FLUTTER_TOOL_ARGS% "%snapshot_path%" %*
SET exit_code=%ERRORLEVEL% SET exit_code=%ERRORLEVEL%
) )
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment