Are all "nil value" log messages errors?

ExpiredReign

Deity
Joined
Jan 3, 2013
Messages
2,450
Location
Tasmania
I'm trying to understand Lua, and programming in general, and I keep coming across log messages which I assume would be errors, but I am not 100% sure if they are.

eg.
Code:
attempt to index field '?' (a nil value)
or
Code:
attempt to index field 'SpecificallyNamedField' (a nil value)
or
Code:
attempt to index a nil value

Here I am assuming the code chunks are looking into a table and expecting to find a field or value of something and instead finds nothing and says as much.

Now is this a fault of the programmer, failing to create the table properly, or looking in the wrong table, or the table just not being populated at the time of the inspection, or just something that happens?

Is it possible to log messages that explicitly state the expected results?

eg.
Code:
attempt to index field 'ThisNamedField' (a nil value)
ERROR: "Expected to find Sheep in this field."

Thanks

Still learning as I go.:D
 
Now is this a fault of the programmer, failing to create the table properly, or looking in the wrong table, or the table just not being populated at the time of the inspection, or just something that happens?

Any of those except the last. It is not something that just happens. If it happens there's an error in the code somewhere. For example you can have a function that return a table of values or nil if there are no values to return. If you then try to loop through the table, without making sure it isn't nil, you'll get an error like that every time it is nil.
 
Back
Top Bottom