Skip to content

Commit 33c2fe4

Browse files
committed
[GR-15915] Convert to intuitive Ruby exceptions when INVOKE fails.
PullRequest: truffleruby/846
2 parents 8716582 + 910aaff commit 33c2fe4

File tree

3 files changed

+8
-6
lines changed

3 files changed

+8
-6
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ Bug fixes:
1010
* Fixed `rb_get_kwargs` to correctly handle optional and rest arguments.
1111
* Calling `Kernel#raise` with a raised exception will no longer set the cause of the exception to itself (#1682).
1212
* Return a `FFI::Function` correctly for functions returning a callback.
13+
* Convert to intuitive Ruby exceptions when INVOKE fails (#1690).
1314

1415
Compatibility
1516

src/main/java/org/truffleruby/core/exception/CoreExceptions.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313

1414
import java.util.EnumSet;
1515

16+
import com.oracle.truffle.api.interop.InteropException;
1617
import com.oracle.truffle.api.source.SourceSection;
1718
import org.jcodings.Encoding;
1819
import org.jcodings.specific.UTF8Encoding;
@@ -661,8 +662,8 @@ public DynamicObject noSuperMethodOutsideMethodError(Node currentNode) {
661662
context.getSymbolTable().getSymbol("<unknown>")));
662663
}
663664

664-
public DynamicObject noMethodErrorUnknownIdentifier(TruffleObject receiver, Object name, Object[] args, UnknownIdentifierException exception, Node currentNode) {
665-
return noMethodError(exception.getMessage(), receiver, name.toString(), args, currentNode);
665+
public DynamicObject noMethodErrorUnknownIdentifier(TruffleObject receiver, String name, Object[] args, InteropException exception, Node currentNode) {
666+
return noMethodError(exception.getMessage(), receiver, name, args, currentNode);
666667
}
667668

668669
// LoadError

src/main/java/org/truffleruby/interop/OutgoingForeignCallNode.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -488,12 +488,12 @@ public Object executeCall(TruffleObject receiver, Object[] args) {
488488
receiver,
489489
name,
490490
arguments);
491-
} catch (UnknownIdentifierException e) {
491+
} catch (UnknownIdentifierException | UnsupportedMessageException e) {
492492
unknownIdentifierProfile.enter();
493493
throw new RaiseException(getContext(), coreExceptions().noMethodErrorUnknownIdentifier(receiver, name, args, e, this));
494-
} catch (UnsupportedTypeException | ArityException | UnsupportedMessageException e) {
495-
exceptionProfile.enter();
496-
throw new JavaException(e);
494+
} catch (UnsupportedTypeException | ArityException e) {
495+
argumentErrorProfile.enter();
496+
throw new RaiseException(getContext(), coreExceptions().argumentError(e.getMessage(), this));
497497
}
498498

499499
return foreignToRubyNode.executeConvert(foreign);

0 commit comments

Comments
 (0)