]> gerrit.simantics Code Review - simantics/platform.git/blobdiff - bundles/org.simantics.scl.compiler/src/org/simantics/scl/compiler/common/exceptions/InternalCompilerError.java
(refs #7866) Better error location for the NPE in compilation
[simantics/platform.git] / bundles / org.simantics.scl.compiler / src / org / simantics / scl / compiler / common / exceptions / InternalCompilerError.java
index 71b6193015b1b4aafb8d9e0cc226131a0f7f928b..1c2709665765562067f185a96bff6ece7243b17a 100644 (file)
@@ -36,5 +36,16 @@ public class InternalCompilerError extends RuntimeException {
         super(cause);
         this.location = location;
     }
+    
+    public static InternalCompilerError injectLocation(long location, Throwable cause) {
+        if(cause instanceof InternalCompilerError) {
+            InternalCompilerError e = (InternalCompilerError)cause;
+            if(e.location == Locations.NO_LOCATION)
+                e.location = location;
+            return e;
+        }
+        else
+            return new InternalCompilerError(location, cause);
+    }
    
 }