Re: will map:put() never fail?
- Posted by DerekParnell (admin) Sep 09, 2011
- 1027 views
euphoric said...
Shouldn't map:put() be a function in case it needs to report an error? I don't see anything like "map:get_error()" either...
Or maybe map:put() will never fail?
It can fail, but if it does it causes a program fail too. It can fail for these reasons ...
- The MAP ID is wrong. Either an invalid value or it refers to an object which isn't a map.
- The OPERATION argument is not a valid value.
- The OPERATION argument is invalid for the case when the KEY does not exist in the map.
- The computer's RAM has been exhausted.
I think that the idea was that if one of these situations arose, then the application is already compromised and cannot continue anyhow.