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

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


local function makeErrorHandler(traceback)
	assert(traceback ~= nil)

	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
