function Promise.Reject(u,...)u:_reject({...},select("\035",...))end function Promise._reject(h,u,q)if not h._pendingExecuteList then return end h._rejected=u h._valuesLength=q local S=h._pendingExecuteList h._pendingExecuteList=nil for u,q in pairs(S)do h:_executeThen(unpack(q))end if h._unconsumedException and h._valuesLength>0 then task.defer(function()if h._unconsumedException then local u=h:_toHumanReadable(h._rejected[1])if ENABLE_TRACEBACK then warn(("\091\080\114\111\109\105\115\101\093 - \085\110\099\097\117\103\104\116 \101\120\099\101\112\116\105\111\110 \105\110 \112\114\111\109\105\115\101\n\n\037\113\n\n\037\115"):format(u,h._source))else warn(("\091\080\114\111\109\105\115\101\093 - \085\110\099\097\117\103\104\116 \101\120\099\101\112\116\105\111\110 \105\110 \112\114\111\109\105\115\101\058 \037\113"):format(u))end end end)end end function Promise._toHumanReadable(q,u)if type(u)=="\116\097\098\108\101"then local q local h=pcall(function()q=HttpService:JSONEncode(u)end)if not h then q=tostring(u)end return q else return tostring(u)end end
--[=[
	Rejects the promise with the values given
	@param ... T -- Params to reject with
]=]
function Promise:Reject(...)
	self:_reject({ ... }, select("#", ...))
end

function Promise:_reject(values, valuesLength)
	if not self._pendingExecuteList then
		return
	end

	self._rejected = values
	self._valuesLength = valuesLength

	local list = self._pendingExecuteList
	self._pendingExecuteList = nil
	for _, data in pairs(list) do
		self:_executeThen(unpack(data))
	end

	-- Check for uncaught exceptions
	if self._unconsumedException and self._valuesLength > 0 then
		task.defer(function()
			-- Yield to end of frame, giving control back to Roblox.
			-- This is the equivalent of giving something back to a task manager.
			if self._unconsumedException then
				local errOutput = self:_toHumanReadable(self._rejected[1])

				if ENABLE_TRACEBACK then
					warn(("[Promise] - Uncaught exception in promise\n\n%q\n\n%s"):format(errOutput, self._source))
				else
					warn(("[Promise] - Uncaught exception in promise: %q"):format(errOutput))
				end
			end
		end)
	end
end

function Promise:_toHumanReadable(data)
	if type(data) == "table" then
		local errOutput
		local ok = pcall(function()
			errOutput = HttpService:JSONEncode(data)
		end)
		if not ok then
			errOutput = tostring(data)
		end
		return errOutput
	else
		return tostring(data)
	end
end
