# HG changeset patch # User Kim Alvefur # Date 1612123803 -3600 # Node ID e10567199f02ad5afd66418a725765adf54cafe2 # Parent 6b541d3c4c1b475acafbd482d8b0986d487347d5 util.adhoc: Propagate error with producing initial initial data Bonus: Allow use of util.error tables diff -r 6b541d3c4c1b -r e10567199f02 util/adhoc.lua --- a/util/adhoc.lua Sun Jan 31 21:11:55 2021 +0100 +++ b/util/adhoc.lua Sun Jan 31 21:10:03 2021 +0100 @@ -23,8 +23,14 @@ 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