# HG changeset patch # User Kim Alvefur # Date 1649346488 -7200 # Node ID 9d0ec61c70a15f80a086b97fb2890647b6e1d91d # Parent 3dc8e329d233189f4451c307cca546bca2f0c5a1 mod_rest: Catch and coerce errors in echo endpoint This should ensure problems in encode() are reported back diff -r 3dc8e329d233 -r 9d0ec61c70a1 mod_rest/mod_rest.lua --- a/mod_rest/mod_rest.lua Thu Apr 07 15:39:57 2022 +0200 +++ b/mod_rest/mod_rest.lua Thu Apr 07 17:48:08 2022 +0200 @@ -332,8 +332,10 @@ local send_type = decide_type((request.headers.accept or "") ..",".. (request.headers.content_type or ""), supported_outputs) if echo then + local ret, err = errors.coerce(encode(send_type, payload)); + if not ret then return err; end response.headers.content_type = send_type; - return encode(send_type, payload); + return ret; end if payload.name == "iq" then