Software /
code /
prosody
Changeset
9749:9361bd1b9c9b
util.error: Add a function for creating an error object from an error stanza
author | Kim Alvefur <zash@zash.se> |
---|---|
date | Sun, 30 Dec 2018 20:30:59 +0100 |
parents | 9748:99199b53019f |
children | 9750:65432dc80d90 |
files | util/error.lua |
diffstat | 1 files changed, 12 insertions(+), 0 deletions(-) [+] |
line wrap: on
line diff
--- a/util/error.lua Sun Dec 30 16:03:15 2018 +0100 +++ b/util/error.lua Sun Dec 30 20:30:59 2018 +0100 @@ -33,8 +33,20 @@ return ok, new_err, ...; end +local function from_stanza(stanza, context) + local error_type, condition, text = stanza:get_error(); + return setmetatable({ + type = error_type or "cancel"; + condition = condition or "undefined-condition"; + text = text; + + context = context or { stanza = stanza }; + }, error_mt); +end + return { new = new; coerce = coerce; is_err = is_err; + from_stanza = from_stanza; }