BeamMP-Server
BeamMP-Server copied to clipboard
[Feature Request] Only return error message from `FS.CreateDirectory()`
The Lua API function FS.CreateDirectory()
currently returns a boolean that is false when an error occurred and the error message. It would be better to just return the error message or nil if there was no error. The boolean is just unnecessary and confusing.
Example
local error_msg = FS.CreateDirectory("path")
if error_msg then
print("Failed to create the directory:", error_msg)
end
PS: The documentation also wrongly states that the boolean is true when there was an error, whereas the inverse is actually true:
Returns whether the operation had an error, and, if it did, an error message. This means that, if true is returned, an error occurred.
The example is also wrong:
local err, error_message = FS.CreateDirectory("data/mystuff/somefolder")
if err then
print("failed to create directory: " .. error_message)
else
-- do something with the directory
end
~~The variable error
in the example from the docs conflicts with Lua's error()
function.~~