diff options
author | Kim Alvefur <zash@zash.se> | 2021-01-31 21:10:03 +0100 |
---|---|---|
committer | Kim Alvefur <zash@zash.se> | 2021-01-31 21:10:03 +0100 |
commit | 739c6859c78cd0d5976525560a0d22c8c67356a0 (patch) | |
tree | 573c3ba493dd59f2c6a6d15ad8e97d86087838e3 /util | |
parent | e2f121eccb01e2c99f9cff6bd31427993f7d6164 (diff) | |
download | prosody-739c6859c78cd0d5976525560a0d22c8c67356a0.tar.gz prosody-739c6859c78cd0d5976525560a0d22c8c67356a0.zip |
util.adhoc: Propagate error with producing initial initial data
Bonus: Allow use of util.error tables
Diffstat (limited to 'util')
-rw-r--r-- | util/adhoc.lua | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/util/adhoc.lua b/util/adhoc.lua index 19c94c34..a0ad52bb 100644 --- a/util/adhoc.lua +++ b/util/adhoc.lua @@ -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 |