diff --git a/gradlew b/gradlew
old mode 100755
new mode 100644
diff --git a/src/main/java/uk/ac/rhul/cs/javatester/CodeTester.java b/src/main/java/uk/ac/rhul/cs/javatester/CodeTester.java
index 630461802ead7b62f87804eebb45e9a109bb8888..9df699cc30fd155481883a3360627f2f4f63c6c2 100644
--- a/src/main/java/uk/ac/rhul/cs/javatester/CodeTester.java
+++ b/src/main/java/uk/ac/rhul/cs/javatester/CodeTester.java
@@ -100,7 +100,14 @@ public class CodeTester {
     public static class StudentCodeException
                   extends BaseTester.FailedTestException {
         private static final long serialVersionUID = -4498256171743133274L;
-        public StudentCodeException(String msg) { super(msg); }
+        private Throwable cause;
+
+        public StudentCodeException(String msg,  Throwable cause) {
+            super(msg);
+            this.cause = cause;
+        }
+
+        public Throwable getCause() { return cause; }
     }
 
     /**
@@ -287,8 +294,9 @@ public class CodeTester {
         }
         catch (InvocationTargetException e) {
             throw new StudentCodeException (
-                expandMsg(invocationMsg) + "\n" +
-                Utils.makeThrowableMsg(e.getCause())
+                expandMsg(invocationMsg) + "\n"
+                    + Utils.makeThrowableMsg(e.getCause()),
+                e.getCause()
             );
         }
         catch (Throwable e) { /* fall through */ }
@@ -388,8 +396,9 @@ public class CodeTester {
 
             if (r == null && !acceptNull) {
                 throw new BaseTester.FailedTestException(
-                    expandMsg(invocationMsg) + "\n\n" +
-                    "The method call returned null but a non-null value was expected."
+                    expandMsg(invocationMsg) + "\n\n"
+                        + "The method call returned null but a non-null "
+                        + "value was expected."
                 );
             }
 
@@ -398,8 +407,9 @@ public class CodeTester {
             return r;
         } catch (InvocationTargetException e) {
             throw new StudentCodeException (
-                expandMsg(invocationMsg) + "\n\n" +
-                Utils.makeThrowableMsg(e.getCause())
+                expandMsg(invocationMsg) + "\n\n"
+                    + Utils.makeThrowableMsg(e.getCause()),
+                e.getCause()
             );
         } catch (BaseTester.FailedTestException e) {
             throw e;
@@ -570,8 +580,9 @@ public class CodeTester {
         }
         catch (InvocationTargetException e) {
             throw new StudentCodeException (
-                expandMsg(invocationMsg) + "\n\n" +
-                Utils.makeThrowableMsg(e.getCause())
+                expandMsg(invocationMsg) + "\n\n"
+                    + Utils.makeThrowableMsg(e.getCause()),
+                e.getCause()
             );
         }
         catch (BaseTester.FailedTestException e) {
@@ -1041,7 +1052,7 @@ public class CodeTester {
     }
 
     /**
-     * Expand properties such as :LOG: and :LAST_CALL:
+     * Expand properties such as :LOG: and :LASTCALL:
      */
     private String expandMsg(String msg) {
         String lastCall = getLastCall();
@@ -1083,8 +1094,7 @@ public class CodeTester {
     private Object invokeMethod(String invocationMsg,
                                 Method m,
                                 Object tis,
-                                Object... params) throws
-                   Throwable {
+                                Object... params) throws Throwable {
         try {
             return Utils.runWithTimeout(getTimeout(),
                                         () -> {
@@ -1119,10 +1129,11 @@ public class CodeTester {
                 if (ite instanceof InvocationTargetException) {
                     Throwable cause = ite.getCause();
                     if (cause != null) {
-                        throw new BaseTester.FailedTestException(
-                            expandMsg(invocationMsg) + "\n\n" +
-                            "Exception while calling method " + m.getName() +
-                            ": " + cause
+                        throw new StudentCodeException(
+                            expandMsg(invocationMsg) + "\n\n"
+                                + "Exception while calling method "
+                                + m.getName() + ": " + cause,
+                            ite.getCause()
                         );
                     }
                 }