Skip to content

Add missing File::NotFoundError exception documentation for File.open #15826

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

Fijxu
Copy link

@Fijxu Fijxu commented May 24, 2025

I think this is missing from the documentation. The PR is self explanatory (I believe)

Fijxu and others added 2 commits May 26, 2025 18:05
Co-authored-by: Johannes Müller <[email protected]>
Co-authored-by: Johannes Müller <[email protected]>
Copy link
Contributor

@Sija Sija left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Language suggestions

#
# ```
# File.write("bar", "foo")
# File.read("bar") # => "foo"
#
# File.read("notexist") # raises File::NotFoundError
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
# File.read("notexist") # raises File::NotFoundError
# File.read("non-existent-file") # raises File::NotFoundError

@@ -524,10 +524,14 @@ class File < IO::FileDescriptor
end

# Returns the content of *filename* as a string.
#
# Raises `File::NotFoundError` if the file at filename does not exist.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Wouldn't it be more accurate to say something around the lines of?

Raises File::Error if the file cannot be accessed for whatever reason.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants