From 6a2e73a724f37167653b18d6a3c669bb5e4c46ea Mon Sep 17 00:00:00 2001 From: James Strachan Date: Thu, 23 Feb 2012 11:53:48 +0000 Subject: [PATCH] add some NPE handling --- .../jetbrains/jet/codegen/CompilationException.java | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/compiler/backend/src/org/jetbrains/jet/codegen/CompilationException.java b/compiler/backend/src/org/jetbrains/jet/codegen/CompilationException.java index d23804df36e..891546c485f 100644 --- a/compiler/backend/src/org/jetbrains/jet/codegen/CompilationException.java +++ b/compiler/backend/src/org/jetbrains/jet/codegen/CompilationException.java @@ -52,13 +52,18 @@ public class CompilationException extends RuntimeException { col = -1; } - String s2 = getCause().getMessage() != null ? getCause().getMessage() : getCause().toString(); + String s2 = ""; + Throwable cause = getCause(); + if (cause != null) { + s2 = cause.getMessage() != null ? cause.getMessage() : cause.toString(); + } return "Internal error: (" + (line+1) + "," + col + ") " + s2 + "\n@" + where(); } private String where() { - if (getCause().getStackTrace().length > 0) { - return getCause().getStackTrace()[0].getFileName() + ":" + getCause().getStackTrace()[0].getLineNumber(); + Throwable cause = getCause(); + if (cause != null && cause.getStackTrace().length > 0) { + return cause.getStackTrace()[0].getFileName() + ":" + cause.getStackTrace()[0].getLineNumber(); } else { return "far away in cyberspace"; }