Software / code / prosody
Comparison
util/error.lua @ 11089:35d2260644d9
util.error: Extract error originator from stanza errors
| author | Kim Alvefur <zash@zash.se> |
|---|---|
| date | Sat, 26 Sep 2020 18:13:27 +0200 |
| parent | 11081:0b68697450c5 |
| child | 11090:33b6fbdcec88 |
comparison
equal
deleted
inserted
replaced
| 11088:1f84d0e4d0c4 | 11089:35d2260644d9 |
|---|---|
| 91 return ok, new_err, ...; | 91 return ok, new_err, ...; |
| 92 end | 92 end |
| 93 | 93 |
| 94 local function from_stanza(stanza, context) | 94 local function from_stanza(stanza, context) |
| 95 local error_type, condition, text = stanza:get_error(); | 95 local error_type, condition, text = stanza:get_error(); |
| 96 local error_tag = stanza:get_child("error"); | |
| 97 context = context or {}; | |
| 98 context.stanza = stanza; | |
| 99 context.by = error_tag.attr.by; | |
| 96 return setmetatable({ | 100 return setmetatable({ |
| 97 type = error_type or "cancel"; | 101 type = error_type or "cancel"; |
| 98 condition = condition or "undefined-condition"; | 102 condition = condition or "undefined-condition"; |
| 99 text = text; | 103 text = text; |
| 100 | 104 |
| 101 context = context or { stanza = stanza }; | 105 context = context; |
| 106 | |
| 102 }, error_mt); | 107 }, error_mt); |
| 103 end | 108 end |
| 104 | 109 |
| 105 return { | 110 return { |
| 106 new = new; | 111 new = new; |