Errors and Promises
Packet Functions use Promises to handle asynchronous results and errors.
Successful Requests
Section titled “Successful Requests”Network.Server.RequestData:Invoke(nil, data):andThen(function(result) print(result)end)Failed Requests
Section titled “Failed Requests”If the callback throws an error, the Promise is rejected.
Example:
Network.Server.RequestData:Invoke(nil, data):catch(function(err) warn(err)end)Server:
Network.Server.RequestData:SetCallback(function() error("Something went wrong!")end)The error is automatically forwarded back to the caller.
Cancelling Requests
Section titled “Cancelling Requests”Promises can be cancelled:
local request = Network.Server.RequestData:Invoke(nil, data)
request:cancel()