|
10 | 10 | package org.truffleruby.interop;
|
11 | 11 |
|
12 | 12 | import java.util.Arrays;
|
13 |
| - |
14 |
| -import com.oracle.truffle.api.object.DynamicObject; |
15 |
| - |
16 |
| -import org.truffleruby.language.RubyBaseNode; |
17 |
| -import org.truffleruby.language.control.JavaException; |
18 |
| -import org.truffleruby.language.control.RaiseException; |
19 |
| -import org.truffleruby.language.dispatch.CallDispatchHeadNode; |
20 |
| -import org.truffleruby.language.dispatch.DispatchNode; |
21 |
| -import org.truffleruby.language.methods.ExceptionTranslatingNode; |
22 |
| -import org.truffleruby.language.methods.UnsupportedOperationBehavior; |
| 13 | +import java.util.stream.Collectors; |
23 | 14 |
|
24 | 15 | import com.oracle.truffle.api.CompilerDirectives;
|
25 | 16 | import com.oracle.truffle.api.CompilerDirectives.TruffleBoundary;
|
|
33 | 24 | import com.oracle.truffle.api.interop.UnsupportedMessageException;
|
34 | 25 | import com.oracle.truffle.api.interop.UnsupportedTypeException;
|
35 | 26 | import com.oracle.truffle.api.nodes.Node;
|
| 27 | +import com.oracle.truffle.api.object.DynamicObject; |
36 | 28 | import com.oracle.truffle.api.profiles.BranchProfile;
|
| 29 | +import org.truffleruby.language.RubyBaseNode; |
| 30 | +import org.truffleruby.language.control.JavaException; |
| 31 | +import org.truffleruby.language.control.RaiseException; |
| 32 | +import org.truffleruby.language.dispatch.CallDispatchHeadNode; |
| 33 | +import org.truffleruby.language.dispatch.DispatchNode; |
| 34 | +import org.truffleruby.language.methods.ExceptionTranslatingNode; |
| 35 | +import org.truffleruby.language.methods.UnsupportedOperationBehavior; |
37 | 36 |
|
38 | 37 | public abstract class OutgoingForeignCallNode extends RubyBaseNode {
|
39 | 38 |
|
@@ -224,14 +223,24 @@ public Object executeCall(TruffleObject receiver, Object[] args) {
|
224 | 223 | node,
|
225 | 224 | receiver,
|
226 | 225 | rubyToForeignArgumentsNode.executeConvert(args));
|
227 |
| - } catch (UnsupportedTypeException | ArityException | UnsupportedMessageException e) { |
| 226 | + } catch (UnsupportedTypeException e) { |
| 227 | + exceptionProfile.enter(); |
| 228 | + throw new RaiseException(getContext(), translate(e)); |
| 229 | + } catch (ArityException | UnsupportedMessageException e) { |
228 | 230 | exceptionProfile.enter();
|
229 | 231 | throw new JavaException(e);
|
230 | 232 | }
|
231 | 233 |
|
232 | 234 | return foreignToRubyNode.executeConvert(foreign);
|
233 | 235 | }
|
234 | 236 |
|
| 237 | + @TruffleBoundary |
| 238 | + private DynamicObject translate(UnsupportedTypeException e) { |
| 239 | + return coreExceptions().typeError( |
| 240 | + "Wrong arguments: " + Arrays.stream(e.getSuppliedValues()).map(Object::toString).collect(Collectors.joining(", ")), |
| 241 | + this); |
| 242 | + } |
| 243 | + |
235 | 244 | }
|
236 | 245 |
|
237 | 246 | protected class SendOutgoingNode extends OutgoingNode {
|
|
0 commit comments