From 3cca51f1ce569f2713d808f5a64dbe29460dc57e Mon Sep 17 00:00:00 2001 From: Helio Machado <0x2b3bfa0+git@googlemail.com> Date: Wed, 26 May 2021 23:23:49 +0200 Subject: [PATCH 1/4] Remove catch-all block for token exceptions --- src/cml.js | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) diff --git a/src/cml.js b/src/cml.js index ed08d7c25..b969a5555 100644 --- a/src/cml.js +++ b/src/cml.js @@ -220,13 +220,7 @@ class CML { } async repo_token_check() { - try { - await this.runner_token(); - } catch (err) { - throw new Error( - 'REPO_TOKEN does not have enough permissions to access workflow API' - ); - } + await this.runner_token(); } async pr_create(opts = {}) { From efdf47a23b71c6d2b92bba072e7283355d249e12 Mon Sep 17 00:00:00 2001 From: Helio Machado <0x2b3bfa0+git@googlemail.com> Date: Thu, 27 May 2021 22:43:53 +0200 Subject: [PATCH 2/4] Expand bad credentials error message --- src/cml.js | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/cml.js b/src/cml.js index b969a5555..bf6a9329a 100644 --- a/src/cml.js +++ b/src/cml.js @@ -220,7 +220,13 @@ class CML { } async repo_token_check() { - await this.runner_token(); + try { + await this.runner_token(); + } catch (error) { + if (error.message === 'Bad credentials') + error.message += ', REPO_TOKEN should be a personal access token' + throw error + } } async pr_create(opts = {}) { From 1ba39ae47e38bdc11700bbd40a9b27deaddca4f6 Mon Sep 17 00:00:00 2001 From: "Restyled.io" Date: Thu, 27 May 2021 20:44:05 +0000 Subject: [PATCH 3/4] Restyled by prettier --- src/cml.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/cml.js b/src/cml.js index bf6a9329a..607e8bcce 100644 --- a/src/cml.js +++ b/src/cml.js @@ -223,10 +223,10 @@ class CML { try { await this.runner_token(); } catch (error) { - if (error.message === 'Bad credentials') - error.message += ', REPO_TOKEN should be a personal access token' - throw error - } + if (error.message === 'Bad credentials') + error.message += ', REPO_TOKEN should be a personal access token'; + throw error; + } } async pr_create(opts = {}) { From cd2d32396c62c0acd2f858a1f79d057e86071658 Mon Sep 17 00:00:00 2001 From: Helio Machado <0x2b3bfa0+git@googlemail.com> Date: Thu, 27 May 2021 22:55:30 +0200 Subject: [PATCH 4/4] Rename error to err It was a lapsus --- src/cml.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/cml.js b/src/cml.js index 607e8bcce..dde0b541c 100644 --- a/src/cml.js +++ b/src/cml.js @@ -222,10 +222,10 @@ class CML { async repo_token_check() { try { await this.runner_token(); - } catch (error) { - if (error.message === 'Bad credentials') - error.message += ', REPO_TOKEN should be a personal access token'; - throw error; + } catch (err) { + if (err.message === 'Bad credentials') + err.message += ', REPO_TOKEN should be a personal access token'; + throw err; } }