Search in sources :

Example 1 with InternalThrowable

use of com.github.anba.es6draft.runtime.internal.InternalThrowable in project es6draft by anba.

the class ModuleOperations method toScriptException.

private static ScriptException toScriptException(ExecutionContext cx, Throwable e, SourceIdentifier moduleId, SourceIdentifier referredId) {
    if (e instanceof CompletionException && e.getCause() != null) {
        e = e.getCause();
    }
    ScriptException exception;
    if (e instanceof NoSuchFileException) {
        exception = new ResolutionException(Messages.Key.ModulesUnresolvedModule, moduleId.toString(), referredId.toString()).toScriptException(cx);
    } else if (e instanceof IOException) {
        exception = newInternalError(cx, e, Messages.Key.ModulesIOException, Objects.toString(e.getMessage(), ""));
    } else if (e instanceof InternalThrowable) {
        exception = ((InternalThrowable) e).toScriptException(cx);
    } else {
        cx.getRuntimeContext().getErrorReporter().accept(cx, e);
        exception = newInternalError(cx, e, Messages.Key.InternalError, Objects.toString(e.getMessage(), ""));
    }
    return exception;
}
Also used : ResolutionException(com.github.anba.es6draft.runtime.modules.ResolutionException) ScriptException(com.github.anba.es6draft.runtime.internal.ScriptException) InternalThrowable(com.github.anba.es6draft.runtime.internal.InternalThrowable) CompletionException(java.util.concurrent.CompletionException) NoSuchFileException(java.nio.file.NoSuchFileException) IOException(java.io.IOException)

Aggregations

InternalThrowable (com.github.anba.es6draft.runtime.internal.InternalThrowable)1 ScriptException (com.github.anba.es6draft.runtime.internal.ScriptException)1 ResolutionException (com.github.anba.es6draft.runtime.modules.ResolutionException)1 IOException (java.io.IOException)1 NoSuchFileException (java.nio.file.NoSuchFileException)1 CompletionException (java.util.concurrent.CompletionException)1