|
1 | 1 | /* |
2 | | - * Copyright (c) 2018, 2024, Oracle and/or its affiliates. All rights reserved. |
| 2 | + * Copyright (c) 2018, 2025, Oracle and/or its affiliates. All rights reserved. |
3 | 3 | * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
4 | 4 | * |
5 | 5 | * The Universal Permissive License (UPL), Version 1.0 |
|
80 | 80 | import java.util.stream.Stream; |
81 | 81 |
|
82 | 82 | import org.graalvm.polyglot.Engine; |
| 83 | +import org.graalvm.polyglot.PolyglotException; |
| 84 | +import org.graalvm.polyglot.Value; |
83 | 85 |
|
84 | 86 | import com.oracle.truffle.js.runtime.JSConfig; |
85 | 87 | import com.oracle.truffle.js.runtime.JSContextOptions; |
86 | | -import com.oracle.truffle.js.runtime.Strings; |
87 | | -import com.oracle.truffle.js.runtime.UserScriptException; |
88 | | -import com.oracle.truffle.js.runtime.objects.JSDynamicObject; |
89 | | -import com.oracle.truffle.js.runtime.objects.JSObject; |
90 | 88 |
|
91 | 89 | public abstract class TestSuite { |
92 | 90 |
|
@@ -533,11 +531,18 @@ public final void logFail(TestFile testFile, String failMessage, Throwable cause |
533 | 531 | } |
534 | 532 |
|
535 | 533 | private static String getDetailedCause(Throwable cause) { |
536 | | - if (cause instanceof UserScriptException) { |
537 | | - UserScriptException use = (UserScriptException) cause; |
538 | | - Object exceptionObject = use.getErrorObject(); |
539 | | - if (exceptionObject instanceof JSDynamicObject) { |
540 | | - return String.valueOf(JSObject.get((JSDynamicObject) exceptionObject, Strings.MESSAGE)); |
| 534 | + if (cause instanceof PolyglotException polyglotException) { |
| 535 | + Value guestObject = polyglotException.getGuestObject(); |
| 536 | + if (guestObject != null) { |
| 537 | + try { |
| 538 | + if (guestObject.hasMembers()) { |
| 539 | + Value message = guestObject.getMember("message"); |
| 540 | + if (message != null) { |
| 541 | + return message.toString(); |
| 542 | + } |
| 543 | + } |
| 544 | + } catch (Exception ignored) { |
| 545 | + } |
541 | 546 | } |
542 | 547 | } |
543 | 548 | return ""; |
|
0 commit comments