From 8a0c0f93647832abfe828a2e8cbac8dd54696d7c Mon Sep 17 00:00:00 2001 From: Ahmad Nassri Date: Tue, 25 Aug 2020 15:05:34 -0400 Subject: [PATCH] fix(debug): output debug message for failed api calls --- action/index.js | 9 ++++++++- action/lib/api.js | 2 +- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/action/index.js b/action/index.js index ce33b9bd..0ee3f54e 100644 --- a/action/index.js +++ b/action/index.js @@ -13,8 +13,15 @@ const inputs = { } // error handler -function errorHandler ({ message, stack }) { +function errorHandler ({ message, stack, request }) { core.error(`${message}\n${stack}`) + + // debugging for API calls + if (request) { + const { method, url, body } = request + core.debug(`${method} ${url} ${body}`) + } + process.exit(1) } diff --git a/action/lib/api.js b/action/lib/api.js index 08891d7f..704c905d 100644 --- a/action/lib/api.js +++ b/action/lib/api.js @@ -12,7 +12,7 @@ export async function approve (octokit, repo, { number }) { }) } -export async function comment (octokit, repo, { number }, body) { // eslint-disable-line camelcase +export async function comment (octokit, repo, { number }, body) { await octokit.issues.createComment({ ...repo, issue_number: number,