mirror of
https://github.com/bjc/prosody.git
synced 2025-04-01 20:27:39 +03:00
util.adhoc: Propagate error with producing initial initial data
Bonus: Allow use of util.error tables
This commit is contained in:
parent
8711e2bedc
commit
72cecbe03c
1 changed files with 7 additions and 1 deletions
|
@ -23,8 +23,14 @@ local function new_initial_data_form(form, initial_data, result_handler)
|
|||
local fields, err = form:data(data.form);
|
||||
return result_handler(fields, err, data);
|
||||
else
|
||||
local values, err = initial_data(data);
|
||||
if type(err) == "table" then
|
||||
return {status = "error"; error = err}
|
||||
elseif type(err) == "string" then
|
||||
return {status = "error"; error = {type = "cancel"; condition = "internal-server-error", err}}
|
||||
end
|
||||
return { status = "executing", actions = {"next", "complete", default = "complete"},
|
||||
form = { layout = form, values = initial_data(data) } }, "executing";
|
||||
form = { layout = form, values = values } }, "executing";
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue