From 18e0d41b748035b5232155bf3eb8e5687c152df2 Mon Sep 17 00:00:00 2001 From: Abhijeet Singh Date: Wed, 21 Mar 2018 18:55:37 +0530 Subject: [PATCH] Added robot.error.log() in catch Added robot.error.log() in catch block. Also, added more fancy colors. :sparkles: --- index.js | 22 +++++++++++++++------- 1 file changed, 15 insertions(+), 7 deletions(-) diff --git a/index.js b/index.js index 2f13af2..919ad4a 100644 --- a/index.js +++ b/index.js @@ -11,11 +11,13 @@ module.exports = (robot) => { // Create the labels. TODO : Add a config file for labels and label colors. try { await Promise.all([ - github.issues.createLabel(context.repo({name: 'pr-available', color: '1381ef'})), - github.issues.createLabel(context.repo({name: 'pr-merged', color: '1381ef'})), - github.issues.createLabel(context.repo({name: 'pr-rejected', color: '1381ef'})) + github.issues.createLabel(context.repo({name: 'pr-available', color: '4CAF50'})), + github.issues.createLabel(context.repo({name: 'pr-merged', color: '673AB7'})), + github.issues.createLabel(context.repo({name: 'pr-rejected', color: 'F44336'})) ]) - } catch (e) {} + } catch (e) { + robot.log.error(e, "Error occured while creating a label: " + e) + } const issueNum = parse(body) if (issueNum) { @@ -26,20 +28,26 @@ module.exports = (robot) => { // Remove pr-rejected label if it exists. try { await github.issues.removeLabel(context.repo({number: issueNum, name: 'pr-rejected'})) - } catch (e) {} + } catch (e) { + robot.log.error(e, "Error occured while removing pr-rejected label: " + e); + } await github.issues.addLabels(context.repo({number: issueNum, labels: ['pr-available']})) } else if (state === 'closed') { // Remove pr-open label if it exists. try { await github.issues.removeLabel(context.repo({number: issueNum, name: 'pr-available'})) - } catch (e) {} + } catch (e) { + robot.log.error(e, "Error occured while removing pr-open label: " + e); + } if (merged) { // Remove pr-rejected label if it exists. try { await github.issues.removeLabel(context.repo({number: issueNum, name: 'pr-rejected'})) - } catch (e) {} + } catch (e) { + robot.error.log(e, "Error occured while removing pr-rejected label: " + e); + } await github.issues.addLabels(context.repo({number: issueNum, labels: ['pr-merged']})) }