Changeset

3843:c065b7670c89

mod_rest: Return a friendly message for parse errors And details in the error context that should be included thanks to previous commit.
author Kim Alvefur <zash@zash.se>
date Wed, 15 Jan 2020 21:41:42 +0100
parents 3842:501c7edc8c37
children 3844:c240934703bc
files mod_rest/mod_rest.lua
diffstat 1 files changed, 1 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/mod_rest/mod_rest.lua	Wed Jan 15 21:38:03 2020 +0100
+++ b/mod_rest/mod_rest.lua	Wed Jan 15 21:41:42 2020 +0100
@@ -73,7 +73,7 @@
 	local payload, err = parse(request.headers.content_type, request.body);
 	if not payload then
 		-- parse fail
-		return errors.new({ code = 400, text = err });
+		return errors.new({ code = 400, text = "Failed to parse payload" }, { error = err, type = request.headers.content_type, data = request.body });
 	end
 	if payload.attr.xmlns then
 		return errors.new({ code = 422, text = "'xmlns' attribute must be empty" });