mojo
mojo copied to clipboard
[stdlib] capture error message in os.remove
for now os.remove
only raises a generic messages when it fails, ideally is should capture the error to have a more explicit message, the concerned code is here:
https://github.com/modularml/mojo/blob/20737dcb02ebf091c77b931e5e8b8abb2d4bb164/stdlib/src/os/os.mojo#L264-L271
can I work on this? This would be my first time contributing :)
Sure, go ahead
@artemiogr97 what's expected here is if the file does not exist, a FileNotFoundError is raised or what exactly? The value for the var error is -1 when the file doesn't exist. Are there other possible values for this error?
only a type of error exists in mojo Error
so for now the idea is to clarify the message that is already raised.
The unlink c function is used to delete the file, as the documentation says the function returns -1 when there is an error but it does not tells you directly what the error was, the error is stored as an error code in the erno variable, you will need to get the representation of this error code as an string.
@artemiogr97 @jennyluciav
There is an issue I've reported concerning errno
, which is relevant to the resolution of your issue.
You can find it here: #2532.
Addressing this could be pivotal for progressing with both our issues.