Forest Logo
search
package_2

error-on-nil-index

By @chipioindustries

Roblox

Mirrored

error-on-nil-index

Throws an error when a nonexistent table index is attempted to be located. Useful for tables of constants and settings. Returns the exact same table passed in.

table errorOnNilIndex(table targetTable, bool shouldApplyToEntireTree)
local errorOnNilIndex = require(script.Parent.errorOnNilIndex)

local myTable = {
	Setting1 = "Hi";
	Setting2 = "Hello!";
	RandomList = {
		test = "hi";
	};
}

errorOnNilIndex(myTable)

print(myTable.RandomList.test2) -- does not throw an error
print(myTable.Setting3) -- throws an error

local myTable2 = {
	Setting1 = "Hi";
	RandomList = {
		test = "hi";
	};
}

errorOnNilIndex(myTable2, true)

print(myTable.RandomList.test2) -- throws an error

Package Details

Install command (Click to copy)


Version

1.2.0

License

AGPL-3.0

error

Legal risk for closed-source games

infoStrongest copyleft: even network use counts as distribution, so running this in a live game plausibly requires releasing your game's entire source under AGPL-3.0. Not recommended for closed-source projects.

infoLicense identified from the packaged LICENSE file; the manifest declared none.

Automated license review — not legal advice.