From 58bda60c88e79f9c024a43d62ad1a63e64263688 Mon Sep 17 00:00:00 2001 From: Chun On Lee Date: Sun, 27 Nov 2016 23:58:21 +0800 Subject: [PATCH] Reveal syntax error in parsing .mention-bot file by leaving a comment (#189) * Refs #188, Add catch block for syntax error in config file * Refs #188, Create comment to notify custom config file parsing error * Refs #188, English improvements of the message --- server.js | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/server.js b/server.js index 71cfc31..d1e8ba7 100644 --- a/server.js +++ b/server.js @@ -163,6 +163,17 @@ async function work(body) { headers: { Accept: 'application/vnd.github.v3.raw+json' } + }).catch(function(e) { + if (e instanceof SyntaxError && repoConfig.actions.indexOf(data.action) !== -1) { + // Syntax error while reading custom configuration file + var message = + 'Unable to parse mention-bot custom configuration file due to a syntax error.\n' + + 'Please check the potential root causes below:\n\n' + + '1. Having comments\n' + + '2. Invalid JSON type\n' + + '3. Having extra "," in the last JSON attribute'; + createComment(data, message); + } }); repoConfig = {...repoConfig, ...configRes};