Software /
code /
prosody
Comparison
util/error.lua @ 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 |
parent | 9746:848fd204708c |
child | 10069:6f317e51544d |
comparison
equal
deleted
inserted
replaced
9748:99199b53019f | 9749:9361bd1b9c9b |
---|---|
31 condition = "undefined-condition"; | 31 condition = "undefined-condition"; |
32 }, error_mt); | 32 }, error_mt); |
33 return ok, new_err, ...; | 33 return ok, new_err, ...; |
34 end | 34 end |
35 | 35 |
36 local function from_stanza(stanza, context) | |
37 local error_type, condition, text = stanza:get_error(); | |
38 return setmetatable({ | |
39 type = error_type or "cancel"; | |
40 condition = condition or "undefined-condition"; | |
41 text = text; | |
42 | |
43 context = context or { stanza = stanza }; | |
44 }, error_mt); | |
45 end | |
46 | |
36 return { | 47 return { |
37 new = new; | 48 new = new; |
38 coerce = coerce; | 49 coerce = coerce; |
39 is_err = is_err; | 50 is_err = is_err; |
51 from_stanza = from_stanza; | |
40 } | 52 } |