From be8432c7dd218ce444c8f8fee0dceb3772fd65c1 Mon Sep 17 00:00:00 2001 From: Kodi Craft Date: Sat, 15 Jun 2024 11:57:26 +0200 Subject: [PATCH] Tweaks and error handling --- .github/workflows/test.yaml | 2 +- index.js | 8 +++++++- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/.github/workflows/test.yaml b/.github/workflows/test.yaml index e5ad3ef..0bc0bd7 100644 --- a/.github/workflows/test.yaml +++ b/.github/workflows/test.yaml @@ -7,7 +7,7 @@ on: jobs: test-action: runs-on: nix - name: Tests that the action works as expected + name: Upload and download test steps: - name: Create sample file run: echo "Hello, world!" > test.txt diff --git a/index.js b/index.js index e3bcf29..59a8729 100644 --- a/index.js +++ b/index.js @@ -42,7 +42,13 @@ try { 'x-salt-name': use_salt ? 'true' : 'false', 'authorization': `Bearer ${token}` } - }).then(response => { return response.text() }) + }).then(response => { + if (!response.ok) { + console.log("Got response: ", response) + throw new Error(`HTTP error! status: ${response.status}`); + } + return response.text() + }) .then(uri => { console.log("Uploaded to: ", uri) core.setOutput('uri', uri)