# HG changeset patch # User Matthew Wild # Date 1582740257 0 # Node ID eb27e51cf2c95c9810339959f6744c42657fe2b4 # Parent 8ac5d9933106d270a6879b0eefc8a21cbf8f2733 mod_rest: Handle uncaught native errors correctly Previously they would slip through and be returned over HTTP with 200 OK. diff -r 8ac5d9933106 -r eb27e51cf2c9 mod_rest/mod_rest.lua --- a/mod_rest/mod_rest.lua Wed Feb 26 17:57:53 2020 +0000 +++ b/mod_rest/mod_rest.lua Wed Feb 26 18:04:17 2020 +0000 @@ -142,7 +142,10 @@ return encode(send_type, result.stanza); end, function (error) - if error.context and error.context.stanza then + if not errors.is_err(error) then + module:log("error", "Uncaught native error: %s", error); + return select(2, errors.coerce(nil, error)); + elseif error.context and error.context.stanza then response.headers.content_type = send_type; module:log("debug", "Sending[rest]: %s", error.context.stanza:top_tag()); return encode(send_type, error.context.stanza);