diff --git a/compiler/backend/src/org/jetbrains/jet/codegen/GenerationState.java b/compiler/backend/src/org/jetbrains/jet/codegen/GenerationState.java index 56b432cf2c9..21c99a991f5 100644 --- a/compiler/backend/src/org/jetbrains/jet/codegen/GenerationState.java +++ b/compiler/backend/src/org/jetbrains/jet/codegen/GenerationState.java @@ -10,6 +10,7 @@ import org.jetbrains.jet.codegen.intrinsics.IntrinsicMethods; import org.jetbrains.jet.lang.cfg.pseudocode.JetControlFlowDataTraceFactory; import org.jetbrains.jet.lang.descriptors.ClassDescriptor; import org.jetbrains.jet.lang.descriptors.ConstructorDescriptor; +import org.jetbrains.jet.lang.diagnostics.DiagnosticUtils; import org.jetbrains.jet.lang.psi.*; import org.jetbrains.jet.lang.resolve.AnalyzingUtils; import org.jetbrains.jet.lang.resolve.BindingContext; @@ -113,6 +114,7 @@ public class GenerationState { } catch (Throwable e) { errorHandler.reportException(e, namespace.getContainingFile().getVirtualFile().getUrl()); + DiagnosticUtils.throwIfRunningOnServer(e); } } } diff --git a/compiler/frontend.java/src/org/jetbrains/jet/lang/resolve/java/AnalyzerFacade.java b/compiler/frontend.java/src/org/jetbrains/jet/lang/resolve/java/AnalyzerFacade.java index 6ad38396927..ad4e1f20d74 100644 --- a/compiler/frontend.java/src/org/jetbrains/jet/lang/resolve/java/AnalyzerFacade.java +++ b/compiler/frontend.java/src/org/jetbrains/jet/lang/resolve/java/AnalyzerFacade.java @@ -11,6 +11,7 @@ import com.intellij.psi.util.PsiModificationTracker; import com.intellij.util.Function; import org.jetbrains.annotations.NotNull; import org.jetbrains.jet.lang.cfg.pseudocode.JetControlFlowDataTraceFactory; +import org.jetbrains.jet.lang.diagnostics.DiagnosticUtils; import org.jetbrains.jet.lang.diagnostics.Errors; import org.jetbrains.jet.lang.psi.JetDeclaration; import org.jetbrains.jet.lang.psi.JetFile; @@ -68,18 +69,8 @@ public class AnalyzerFacade { throw e; } catch (Throwable e) { - // This is needed for the Web Demo server to log the exceptions coming from the analyzer instead of showing them in the editor. - if (System.getProperty("kotlin.running.in.server.mode", "false").equals("true")) { - if (e instanceof RuntimeException) { - RuntimeException runtimeException = (RuntimeException) e; - throw runtimeException; - } - if (e instanceof Error) { - Error error = (Error) e; - throw error; - } - throw new RuntimeException(e); - } + DiagnosticUtils.throwIfRunningOnServer(e); + e.printStackTrace(); BindingTraceContext bindingTraceContext = new BindingTraceContext(); bindingTraceContext.report(Errors.EXCEPTION_WHILE_ANALYZING.on(file, e)); @@ -93,5 +84,4 @@ public class AnalyzerFacade { } return bindingContextCachedValue.getValue(); } - } diff --git a/compiler/frontend/src/org/jetbrains/jet/lang/diagnostics/DiagnosticUtils.java b/compiler/frontend/src/org/jetbrains/jet/lang/diagnostics/DiagnosticUtils.java index 0ff433add71..0e85d64ce6d 100644 --- a/compiler/frontend/src/org/jetbrains/jet/lang/diagnostics/DiagnosticUtils.java +++ b/compiler/frontend/src/org/jetbrains/jet/lang/diagnostics/DiagnosticUtils.java @@ -81,4 +81,19 @@ public class DiagnosticUtils { } return position; } + + public static void throwIfRunningOnServer(Throwable e) { + // This is needed for the Web Demo server to log the exceptions coming from the analyzer instead of showing them in the editor. + if (System.getProperty("kotlin.running.in.server.mode", "false").equals("true")) { + if (e instanceof RuntimeException) { + RuntimeException runtimeException = (RuntimeException) e; + throw runtimeException; + } + if (e instanceof Error) { + Error error = (Error) e; + throw error; + } + throw new RuntimeException(e); + } + } }