mirror of
https://github.com/bjc/prosody.git
synced 2025-04-03 21:27:38 +03:00
util.error: Add a function for creating an error object from an error stanza
This commit is contained in:
parent
f102941562
commit
3b3af4805c
1 changed files with 12 additions and 0 deletions
|
@ -33,8 +33,20 @@ local function coerce(ok, err, ...)
|
|||
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;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue