Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added robot.error.log() in catch #3

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 15 additions & 7 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand All @@ -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']}))
}
Expand Down