From 8dd281366823c022c869b94bc8d8bfcef1468c70 Mon Sep 17 00:00:00 2001 From: Peter Evans <18365890+peter-evans@users.noreply.github.com> Date: Tue, 27 Oct 2020 10:41:21 +0900 Subject: [PATCH] fix: throw errors on request failure --- dist/index.js | 4 ++++ src/dockerhub-helper.ts | 4 ++++ 2 files changed, 8 insertions(+) diff --git a/dist/index.js b/dist/index.js index f334ed8..e036381 100644 --- a/dist/index.js +++ b/dist/index.js @@ -72,6 +72,10 @@ function updateRepositoryDescription(token, repository, description, fullDescrip 'Content-Type': 'application/json', Authorization: `JWT ${token}` } + }).then(res => { + if (!res.ok) { + throw new Error(res.statusText); + } }); }); } diff --git a/src/dockerhub-helper.ts b/src/dockerhub-helper.ts index 1aeccd8..c63737e 100644 --- a/src/dockerhub-helper.ts +++ b/src/dockerhub-helper.ts @@ -40,5 +40,9 @@ export async function updateRepositoryDescription( 'Content-Type': 'application/json', Authorization: `JWT ${token}` } + }).then(res => { + if (!res.ok) { + throw new Error(res.statusText) + } }) }