diff --git a/src/main/java/com/github/anba/es6draft/runtime/modules/ResolutionException.java b/src/main/java/com/github/anba/es6draft/runtime/modules/ResolutionException.java index 916624aaa..72fa1be29 100644 --- a/src/main/java/com/github/anba/es6draft/runtime/modules/ResolutionException.java +++ b/src/main/java/com/github/anba/es6draft/runtime/modules/ResolutionException.java @@ -53,4 +53,8 @@ public String getLocalizedMessage() { public ScriptException toScriptException(ExecutionContext cx) { throw Errors.newSyntaxError(cx, this, messageKey, messageArguments); } + + public String getScriptMessage(ExecutionContext cx) { + return Errors.newSyntaxError(cx, this, messageKey, messageArguments).getMessage(cx); + } } diff --git a/src/test/java/com/github/anba/es6draft/util/matchers/ErrorMessageMatcher.java b/src/test/java/com/github/anba/es6draft/util/matchers/ErrorMessageMatcher.java index a250c6a8b..331a34837 100644 --- a/src/test/java/com/github/anba/es6draft/util/matchers/ErrorMessageMatcher.java +++ b/src/test/java/com/github/anba/es6draft/util/matchers/ErrorMessageMatcher.java @@ -13,6 +13,7 @@ import com.github.anba.es6draft.runtime.ExecutionContext; import com.github.anba.es6draft.runtime.internal.Messages; import com.github.anba.es6draft.runtime.internal.ScriptException; +import com.github.anba.es6draft.runtime.modules.ResolutionException; /** * {@link Matcher} for script execution error messages. @@ -54,6 +55,9 @@ private String getMessage(T error) { if (error instanceof StackOverflowError) { return String.format("InternalError: %s", cx.getRealm().message(Messages.Key.StackOverflow)); } + if (error instanceof ResolutionException) { + return ((ResolutionException) error).getScriptMessage(cx); + } return error.getMessage(); } } diff --git a/src/test/java/com/github/anba/es6draft/util/rules/ExceptionHandlers.java b/src/test/java/com/github/anba/es6draft/util/rules/ExceptionHandlers.java index f147b5261..762eec085 100644 --- a/src/test/java/com/github/anba/es6draft/util/rules/ExceptionHandlers.java +++ b/src/test/java/com/github/anba/es6draft/util/rules/ExceptionHandlers.java @@ -21,6 +21,7 @@ import com.github.anba.es6draft.repl.global.StopExecutionException; import com.github.anba.es6draft.runtime.ExecutionContext; import com.github.anba.es6draft.runtime.internal.ScriptException; +import com.github.anba.es6draft.runtime.modules.ResolutionException; import com.github.anba.es6draft.util.TestAssertions; /** @@ -42,12 +43,12 @@ private static Iterable asIterable(Supplier> stream) { } /** - * {@link ExceptionHandler} for {@link ParserException}, {@link CompilationException} and {@link StackOverflowError} - * errors. + * {@link ExceptionHandler} for {@link ParserException}, {@link CompilationException}, {@link StackOverflowError} + * and {@link ResolutionException} errors. */ public static final class StandardErrorHandler extends ExceptionHandler { private static final Matcher defaultMatcher = anyInstanceOf(ParserException.class, - CompilationException.class, StackOverflowError.class); + CompilationException.class, StackOverflowError.class, ResolutionException.class); public StandardErrorHandler() { this(defaultMatcher()); @@ -110,11 +111,12 @@ public static Matcher defaultMatcher() { /** * {@link ExceptionHandler} for {@link ParserException}, {@link CompilationException}, {@link StackOverflowError} - * and {@link ScriptException} errors. + * {@link ScriptException}, and {@link ResolutionException} errors. */ public static final class IgnoreExceptionHandler extends ExceptionHandler { private static final Matcher defaultMatcher = anyInstanceOf(ParserException.class, - CompilationException.class, StackOverflowError.class, ScriptException.class); + CompilationException.class, StackOverflowError.class, ScriptException.class, + ResolutionException.class); public IgnoreExceptionHandler() { this(defaultMatcher());