mojo icon indicating copy to clipboard operation
mojo copied to clipboard

[stdlib] capture error message in os.remove

Open artemiogr97 opened this issue 10 months ago • 5 comments

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

artemiogr97 avatar Apr 19 '24 20:04 artemiogr97

can I work on this? This would be my first time contributing :)

jennyluciav avatar May 03 '24 18:05 jennyluciav

Sure, go ahead

artemiogr97 avatar May 03 '24 20:05 artemiogr97

@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?

jennyluciav avatar May 04 '24 00:05 jennyluciav

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 avatar May 04 '24 08:05 artemiogr97

@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.

dayeondev avatar May 15 '24 10:05 dayeondev