Comparison

util/error.lua @ 11079:1e5a0e0469de

util.error: Switch coerce() to use new() and change 'native' to context field 'wrapped_error'
author Matthew Wild <mwild1@gmail.com>
date Fri, 25 Sep 2020 12:38:58 +0100
parent 11078:fb3aec3dbe21
child 11080:ba77c142c9b1
comparison
equal deleted inserted replaced
11078:fb3aec3dbe21 11079:1e5a0e0469de
68 local function coerce(ok, err, ...) 68 local function coerce(ok, err, ...)
69 if ok or is_err(err) then 69 if ok or is_err(err) then
70 return ok, err, ...; 70 return ok, err, ...;
71 end 71 end
72 72
73 local new_err = setmetatable({ 73 local new_err = new({
74 native = err; 74 type = "cancel", condition = "undefined-condition"
75 }, { wrapped_error = err });
75 76
76 type = "cancel";
77 condition = "undefined-condition";
78 }, error_mt);
79 return ok, new_err, ...; 77 return ok, new_err, ...;
80 end 78 end
81 79
82 local function from_stanza(stanza, context) 80 local function from_stanza(stanza, context)
83 local error_type, condition, text = stanza:get_error(); 81 local error_type, condition, text = stanza:get_error();