Software /
code /
prosody-modules
Diff
mod_rest/mod_rest.lua @ 4917:9d0ec61c70a1
mod_rest: Catch and coerce errors in echo endpoint
This should ensure problems in encode() are reported back
author | Kim Alvefur <zash@zash.se> |
---|---|
date | Thu, 07 Apr 2022 17:48:08 +0200 |
parent | 4888:dc7c9ae15f43 |
child | 4918:347e34c3c7e2 |
line wrap: on
line diff
--- 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