Skip to content
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

Incorrect exception message for exceptions that inherit from Errno exceptions #2521

Closed
postmodern opened this issue Nov 2, 2021 · 3 comments
Assignees
Milestone

Comments

@postmodern
Copy link

I noticed that TruffleRuby deviates from CRuby when an exception inherits from an Errno exception. The inherited Errno message (ex: No such file or directory) becomes lost.

Example

class CustomError < Errno::ENOENT
end

raise(CustomError,"custom message")

CRuby (3.0.2)

(irb):4:in `<main>': No such file or directory - custom message (CustomError)

TruffleRuby (21.3.0)

(irb):4:in `<top (required)>': unknown error - custom message (CustomError)
@eregon
Copy link
Member

eregon commented Nov 2, 2021

Thanks for the report.

@bjfish Could you look into this?
I think this condition is problematic: if error && error.class.equal?(self) and I guess we need to pass the self (the exception class) to SystemCallError.errno_error. The other usage of SystemCallError.errno_error doesn't know the correct class so we should probably split the logic to map errno->class to a separate Primitive.

@eregon
Copy link
Member

eregon commented Nov 2, 2021

Actually it might already work by changing error.class.equal?(self) to something like Primitive.object_kind_of?(error, self) since there is a super(*args) call which might deal fine with such cases.

@bjfish
Copy link
Contributor

bjfish commented Nov 5, 2021

This is now fixed at 5776ef6.

@bjfish bjfish closed this as completed Nov 5, 2021
@bjfish bjfish added this to the 22.0.0 milestone Nov 5, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants