local function t(t,...)return t,select("\035",...),{...}end local function F(t)assert(t~=nil,"\078\111 \116\114\097\099\101\098\097\099\107")return function(F)if type(F)=="\116\097\098\108\101"then return F end return Error.new({error=F,kind=Error.Kind.ExecutionError;trace=debug.traceback(tostring(F),2),context="\080\114\111\109\105\115\101 \099\114\101\097\116\101\100 \097\116\058\n\n"..t})end end

local function packResult(success, ...)
	return success, select("#", ...), { ... }
end


local function makeErrorHandler(traceback)
	assert(traceback ~= nil, "No traceback")

	return function(err)
		-- If the error object is already a table, forward it directly.
		-- Should we extend the error here and add our own trace?

		if type(err) == "table" then
			return err
		end

		return Error.new({
			error = err,
			kind = Error.Kind.ExecutionError,
			trace = debug.traceback(tostring(err), 2),
			context = "Promise created at:\n\n" .. traceback,
		})
	end
end
