mod_rest/mod_rest.lua
changeset 3913 eb27e51cf2c9
parent 3891 3d0e8e32453c
child 3914 49efd1323a1b
equal deleted inserted replaced
3912:8ac5d9933106 3913:eb27e51cf2c9
   140 				module:log("debug", "Sending[rest]: %s", result.stanza:top_tag());
   140 				module:log("debug", "Sending[rest]: %s", result.stanza:top_tag());
   141 				response.headers.content_type = send_type;
   141 				response.headers.content_type = send_type;
   142 				return encode(send_type, result.stanza);
   142 				return encode(send_type, result.stanza);
   143 			end,
   143 			end,
   144 			function (error)
   144 			function (error)
   145 				if error.context and error.context.stanza then
   145 				if not errors.is_err(error) then
       
   146 					module:log("error", "Uncaught native error: %s", error);
       
   147 					return select(2, errors.coerce(nil, error));
       
   148 				elseif error.context and error.context.stanza then
   146 					response.headers.content_type = send_type;
   149 					response.headers.content_type = send_type;
   147 					module:log("debug", "Sending[rest]: %s", error.context.stanza:top_tag());
   150 					module:log("debug", "Sending[rest]: %s", error.context.stanza:top_tag());
   148 					return encode(send_type, error.context.stanza);
   151 					return encode(send_type, error.context.stanza);
   149 				else
   152 				else
   150 					return error;
   153 					return error;