From 59c4596271bf69ded0f1d94195e9b36f5ad995cd Mon Sep 17 00:00:00 2001 From: Markus Fleschutz Date: Thu, 3 Mar 2022 09:49:58 +0100 Subject: [PATCH] Improve the error messages --- Scripts/clean-repo.ps1 | 4 ++-- Scripts/clean-repos.ps1 | 4 ++-- Scripts/remove-tag.ps1 | 4 ++-- Scripts/start-ipfs-server.ps1 | 10 +++++----- Scripts/switch-branch.ps1 | 10 +++++----- 5 files changed, 16 insertions(+), 16 deletions(-) diff --git a/Scripts/clean-repo.ps1 b/Scripts/clean-repo.ps1 index 3fc5bac2..e28deb2e 100755 --- a/Scripts/clean-repo.ps1 +++ b/Scripts/clean-repo.ps1 @@ -27,11 +27,11 @@ try { "⏳ Step 2/3: Cleaning repository..." & git -C "$RepoDir" clean -xfd -f # force + recurse into dirs + don't use the standard ignore rules - if ($lastExitCode -ne "0") { throw "'git clean -xfd -f' failed (exited with $lastExitCode)" } + if ($lastExitCode -ne "0") { throw "'git clean -xfd -f' failed with exit code $lastExitCode)" } "⏳ Step 3/3: Cleaning submodules..." & git -C "$RepoDir" submodule foreach --recursive git clean -xfd -f - if ($lastExitCode -ne "0") { throw "'git clean -xfd -f' in submodules failed (exited with $lastExitCode)" } + if ($lastExitCode -ne "0") { throw "'git clean -xfd -f' in submodules failed with exit code $lastExitCode)" } $RepoDirName = (get-item "$RepoDir").Name [int]$Elapsed = $StopWatch.Elapsed.TotalSeconds diff --git a/Scripts/clean-repos.ps1 b/Scripts/clean-repos.ps1 index 0abffbe4..c3570bf4 100755 --- a/Scripts/clean-repos.ps1 +++ b/Scripts/clean-repos.ps1 @@ -34,10 +34,10 @@ try { "⏳ Step $Step/$($FolderCount): Cleaning 📂$FolderName..." & git -C "$Folder" clean -xfd -f # force + recurse into dirs + don't use the standard ignore rules - if ($lastExitCode -ne "0") { throw "'git clean -xfd -f' failed" } + if ($lastExitCode -ne "0") { throw "'git clean -xfd -f' failed with exit code $lastExitCode" } & git -C "$Folder" submodule foreach --recursive git clean -xfd -f - if ($lastExitCode -ne "0") { throw "'git clean -xfd -f' in submodules failed" } + if ($lastExitCode -ne "0") { throw "'git clean -xfd -f' in submodules failed with exit code $lastExitCode" } $Step++ } diff --git a/Scripts/remove-tag.ps1 b/Scripts/remove-tag.ps1 index 76fdbdb3..3a4cc53e 100755 --- a/Scripts/remove-tag.ps1 +++ b/Scripts/remove-tag.ps1 @@ -33,13 +33,13 @@ try { if (($Mode -eq "locally") -or ($Mode -eq "both")) { "Removing local tag..." & git -C "$RepoDir" tag --delete $TagName - if ($lastExitCode -ne "0") { throw "'git tag --delete' failed" } + if ($lastExitCode -ne "0") { throw "'git tag --delete' failed with exit code $lastExitCode" } } if (($Mode -eq "remote") -or ($Mode -eq "both")) { "Removing remote tag..." & git -C "$RepoDir" push origin :refs/tags/$TagName - if ($lastExitCode -ne "0") { throw "'git push origin' failed" } + if ($lastExitCode -ne "0") { throw "'git push origin' failed with exit code $lastExitCode" } } [int]$Elapsed = $StopWatch.Elapsed.TotalSeconds diff --git a/Scripts/start-ipfs-server.ps1 b/Scripts/start-ipfs-server.ps1 index 11c15c93..012f9a36 100755 --- a/Scripts/start-ipfs-server.ps1 +++ b/Scripts/start-ipfs-server.ps1 @@ -23,21 +23,21 @@ try { "⏳ Step 3/5: Configuring IPFS..." & ipfs config Addresses.API /ip4/0.0.0.0/tcp/5001 - if ($lastExitCode -ne "0") { throw "'ipfs config Addresses.API' failed" } + if ($lastExitCode -ne "0") { throw "'ipfs config Addresses.API' failed (exit code $lastExitCode)" } & ipfs config Addresses.Gateway /ip4/0.0.0.0/tcp/8765 - if ($lastExitCode -ne "0") { throw "'ipfs config Addresses.Gateway' failed" } + if ($lastExitCode -ne "0") { throw "'ipfs config Addresses.Gateway' failed (exit code $lastExitCode)" } $Hostname = $(hostname) & ipfs config --json API.HTTPHeaders.Access-Control-Allow-Origin '[\"http://paris:5001\", \"http://localhost:3000\", \"http://127.0.0.1:5001\", \"https://webui.ipfs.io\"]' - if ($lastExitCode -ne "0") { throw "'ipfs config Access-Control-Allow-Origin' failed" } + if ($lastExitCode -ne "0") { throw "'ipfs config Access-Control-Allow-Origin' failed (exit code $lastExitCode)" } & ipfs config --json API.HTTPHeaders.Access-Control-Allow-Methods '[\"PUT\", \"POST\"]' - if ($lastExitCode -ne "0") { throw "'ipfs config Access-Control-Allow-Methods' failed" } + if ($lastExitCode -ne "0") { throw "'ipfs config Access-Control-Allow-Methods' failed (exit code $lastExitCode)" } "" "⏳ Step 4/5: Increasing UDP receive buffer size..." & sudo sysctl -w net.core.rmem_max=2500000 - if ($lastExitCode -ne "0") { throw "'sysctl' failed" } + if ($lastExitCode -ne "0") { throw "'sysctl' failed (exit code $lastExitCode)" } "" "⏳ Step 5/5: Starting IPFS daemon..." # Start-Process nohup 'ipfs daemon' diff --git a/Scripts/switch-branch.ps1 b/Scripts/switch-branch.ps1 index 2b108048..a6499607 100755 --- a/Scripts/switch-branch.ps1 +++ b/Scripts/switch-branch.ps1 @@ -31,24 +31,24 @@ try { if ($lastExitCode -ne "0") { throw "Can't execute 'git' - make sure Git is installed and available" } $Result = (git status) - if ($lastExitCode -ne "0") { throw "'git status' failed in $RepoDir" } + if ($lastExitCode -ne "0") { throw "'git status' in $RepoDir failed with exit code $lastExitCode" } if ("$Result" -notmatch "nothing to commit, working tree clean") { throw "Git repository is NOT clean: $Result" } "⏳ Step 2/5: Fetching latest updates..." & git fetch --all --recurse-submodules --prune --prune-tags --force - if ($lastExitCode -ne "0") { throw "'git fetch' failed" } + if ($lastExitCode -ne "0") { throw "'git fetch --all' failed with exit code $lastExitCode" } "⏳ Step 3/5: Switching branch..." & git checkout --recurse-submodules "$BranchName" - if ($lastExitCode -ne "0") { throw "'git checkout $BranchName' failed" } + if ($lastExitCode -ne "0") { throw "'git checkout $BranchName' failed with exit code $lastExitCode" } "⏳ Step 4/5: Pulling updates..." & git pull --recurse-submodules - if ($lastExitCode -ne "0") { throw "'git pull' failed" } + if ($lastExitCode -ne "0") { throw "'git pull' failed with exit code $lastExitCode" } "⏳ Step 5/5: Updating submodules..." & git submodule update --init --recursive - if ($lastExitCode -ne "0") { throw "'git submodule update' failed" } + if ($lastExitCode -ne "0") { throw "'git submodule update --init --recursive' failed with exit code $lastExitCode" } $RepoDirName = (get-item "$RepoDir").Name [int]$Elapsed = $StopWatch.Elapsed.TotalSeconds