diff --git a/compiler/cli/src/org/jetbrains/kotlin/cli/js/K2JSCompiler.java b/compiler/cli/src/org/jetbrains/kotlin/cli/js/K2JSCompiler.java index 2aa1797f027..d4b6b02b9fe 100644 --- a/compiler/cli/src/org/jetbrains/kotlin/cli/js/K2JSCompiler.java +++ b/compiler/cli/src/org/jetbrains/kotlin/cli/js/K2JSCompiler.java @@ -55,6 +55,7 @@ import org.jetbrains.kotlin.js.facade.MainCallParameters; import org.jetbrains.kotlin.js.facade.TranslationResult; import org.jetbrains.kotlin.progress.ProgressIndicatorAndCompilationCanceledStatus; import org.jetbrains.kotlin.psi.KtFile; +import org.jetbrains.kotlin.utils.ExceptionUtilsKt; import org.jetbrains.kotlin.utils.PathUtil; import java.io.File; @@ -169,8 +170,9 @@ public class K2JSCompiler extends CLICompiler { try { //noinspection unchecked translationResult = translator.translate(sourcesFiles, mainCallParameters, jsAnalysisResult); - } catch (Exception e) { - throw new RuntimeException(e); + } + catch (Exception e) { + throw ExceptionUtilsKt.rethrow(e); } ProgressIndicatorAndCompilationCanceledStatus.checkCanceled(); diff --git a/js/js.tests/test/org/jetbrains/kotlin/js/test/semantics/NumberTest.java b/js/js.tests/test/org/jetbrains/kotlin/js/test/semantics/NumberTest.java index c86347d8a7a..f604983de8c 100644 --- a/js/js.tests/test/org/jetbrains/kotlin/js/test/semantics/NumberTest.java +++ b/js/js.tests/test/org/jetbrains/kotlin/js/test/semantics/NumberTest.java @@ -16,9 +16,7 @@ package org.jetbrains.kotlin.js.test.semantics; -import org.jetbrains.kotlin.js.facade.exceptions.TranslationInternalException; import org.jetbrains.kotlin.js.test.SingleFileTranslationTest; -import org.junit.Assert; public final class NumberTest extends SingleFileTranslationTest { public NumberTest() { @@ -56,14 +54,7 @@ public final class NumberTest extends SingleFileTranslationTest { } public void testHexadecimalConstant() throws Exception { - try { - fooBoxTest(); - } - catch (TranslationInternalException e) { - Throwable cause = e.getCause(); - Assert.assertTrue(cause instanceof IllegalStateException); - Assert.assertTrue(cause.getMessage().startsWith("Unsupported long constant ")); - } + fooBoxTest(); } public void testNumberCompareTo() throws Exception { diff --git a/js/js.translator/src/org/jetbrains/kotlin/js/facade/exceptions/MainFunctionNotFoundException.java b/js/js.translator/src/org/jetbrains/kotlin/js/facade/exceptions/MainFunctionNotFoundException.java deleted file mode 100644 index 7253024fbc6..00000000000 --- a/js/js.translator/src/org/jetbrains/kotlin/js/facade/exceptions/MainFunctionNotFoundException.java +++ /dev/null @@ -1,25 +0,0 @@ -/* - * Copyright 2010-2015 JetBrains s.r.o. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.jetbrains.kotlin.js.facade.exceptions; - -import org.jetbrains.annotations.NotNull; - -public class MainFunctionNotFoundException extends TranslationException { - public MainFunctionNotFoundException(@NotNull String message) { - super(message); - } -} diff --git a/js/js.translator/src/org/jetbrains/kotlin/js/facade/exceptions/TranslationException.java b/js/js.translator/src/org/jetbrains/kotlin/js/facade/exceptions/TranslationException.java index 296386d15d1..3d6a77be9df 100644 --- a/js/js.translator/src/org/jetbrains/kotlin/js/facade/exceptions/TranslationException.java +++ b/js/js.translator/src/org/jetbrains/kotlin/js/facade/exceptions/TranslationException.java @@ -19,15 +19,6 @@ package org.jetbrains.kotlin.js.facade.exceptions; import org.jetbrains.annotations.NotNull; public class TranslationException extends Exception { - - public TranslationException(@NotNull String message) { - super(message); - } - - public TranslationException(@NotNull Throwable cause) { - super(cause); - } - public TranslationException(@NotNull String message, @NotNull Exception cause) { super(message, cause); } diff --git a/js/js.translator/src/org/jetbrains/kotlin/js/facade/exceptions/TranslationInternalException.java b/js/js.translator/src/org/jetbrains/kotlin/js/facade/exceptions/TranslationInternalException.java deleted file mode 100644 index b2809e66ac9..00000000000 --- a/js/js.translator/src/org/jetbrains/kotlin/js/facade/exceptions/TranslationInternalException.java +++ /dev/null @@ -1,26 +0,0 @@ -/* - * Copyright 2010-2015 JetBrains s.r.o. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.jetbrains.kotlin.js.facade.exceptions; - -import org.jetbrains.annotations.NotNull; - -public class TranslationInternalException extends TranslationException { - - public TranslationInternalException(@NotNull Throwable cause) { - super(cause); - } -} diff --git a/js/js.translator/src/org/jetbrains/kotlin/js/translate/general/Translation.java b/js/js.translator/src/org/jetbrains/kotlin/js/translate/general/Translation.java index d005ba69758..03b9140391c 100644 --- a/js/js.translator/src/org/jetbrains/kotlin/js/translate/general/Translation.java +++ b/js/js.translator/src/org/jetbrains/kotlin/js/translate/general/Translation.java @@ -24,7 +24,9 @@ import org.jetbrains.kotlin.descriptors.ModuleDescriptor; import org.jetbrains.kotlin.idea.MainFunctionDetector; import org.jetbrains.kotlin.js.config.Config; import org.jetbrains.kotlin.js.facade.MainCallParameters; -import org.jetbrains.kotlin.js.facade.exceptions.*; +import org.jetbrains.kotlin.js.facade.exceptions.TranslationException; +import org.jetbrains.kotlin.js.facade.exceptions.TranslationRuntimeException; +import org.jetbrains.kotlin.js.facade.exceptions.UnsupportedFeatureException; import org.jetbrains.kotlin.js.translate.callTranslator.CallTranslator; import org.jetbrains.kotlin.js.translate.context.Namer; import org.jetbrains.kotlin.js.translate.context.StaticContext; @@ -46,6 +48,7 @@ import org.jetbrains.kotlin.psi.KtFile; import org.jetbrains.kotlin.psi.KtNamedFunction; import org.jetbrains.kotlin.resolve.BindingTrace; import org.jetbrains.kotlin.resolve.bindingContextUtil.BindingContextUtilsKt; +import org.jetbrains.kotlin.utils.ExceptionUtilsKt; import java.util.Collection; import java.util.Collections; @@ -164,11 +167,13 @@ public final class Translation { } @NotNull - public static TranslationContext generateAst(@NotNull BindingTrace bindingTrace, - @NotNull Collection files, @NotNull MainCallParameters mainCallParameters, + public static TranslationContext generateAst( + @NotNull BindingTrace bindingTrace, + @NotNull Collection files, + @NotNull MainCallParameters mainCallParameters, @NotNull ModuleDescriptor moduleDescriptor, - @NotNull Config config) - throws TranslationException { + @NotNull Config config + ) throws TranslationException { try { return doGenerateAst(bindingTrace, files, mainCallParameters, moduleDescriptor, config); } @@ -176,7 +181,7 @@ public final class Translation { throw new UnsupportedFeatureException("Unsupported feature used.", e); } catch (Throwable e) { - throw new TranslationInternalException(e); + throw ExceptionUtilsKt.rethrow(e); } } @@ -184,7 +189,8 @@ public final class Translation { private static TranslationContext doGenerateAst(@NotNull BindingTrace bindingTrace, @NotNull Collection files, @NotNull MainCallParameters mainCallParameters, @NotNull ModuleDescriptor moduleDescriptor, - @NotNull Config config) throws MainFunctionNotFoundException { + @NotNull Config config + ) { StaticContext staticContext = StaticContext.generateStaticContext(bindingTrace, config, moduleDescriptor); JsProgram program = staticContext.getProgram(); JsBlock block = program.getGlobalBlock(); @@ -226,8 +232,9 @@ public final class Translation { //TODO: determine whether should throw exception @Nullable - private static JsStatement generateCallToMain(@NotNull TranslationContext context, @NotNull Collection files, - @NotNull List arguments) throws MainFunctionNotFoundException { + private static JsStatement generateCallToMain( + @NotNull TranslationContext context, @NotNull Collection files, @NotNull List arguments + ) { MainFunctionDetector mainFunctionDetector = new MainFunctionDetector(context.bindingContext()); KtNamedFunction mainFunction = mainFunctionDetector.getMainFunction(files); if (mainFunction == null) {