changeset 3097:c7f4e3987ed0

mod_slack_webhooks: Fix error handling for JSON parsing util.json follows the return nil,errmsg pattern, it does not throw hard error as this code seemed to expect
author Kim Alvefur <zash@zash.se>
date Sun, 03 Jun 2018 01:34:23 +0200
parents 420391fd56e5
children a81456a13797
files mod_slack_webhooks/mod_slack_webhooks.lua
diffstat 1 files changed, 2 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/mod_slack_webhooks/mod_slack_webhooks.lua	Sun Jun 03 01:31:40 2018 +0200
+++ b/mod_slack_webhooks/mod_slack_webhooks.lua	Sun Jun 03 01:34:23 2018 +0200
@@ -97,7 +97,8 @@
 	if body_type == "application/x-www-form-urlencoded" then
 		post_body = formdecode(request.body);
 	elseif body_type == "application/json" then
-		if not pcall(function() post_body = json.decode(request.body) end) then
+		post_body = json.decode(request.body)
+		if not post_body then
 			return 420;
 		end
 	else