changeset 1125:442abdfff437

include luan stack in LuanException.printStackTrace()
author Franklin Schmidt <fschmidt@gmail.com>
date Thu, 24 Aug 2017 14:03:36 -0600
parents ea7112e9eb1d
children ffb47187f02f
files src/luan/LuanException.java
diffstat 1 files changed, 21 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
diff -r ea7112e9eb1d -r 442abdfff437 src/luan/LuanException.java
--- a/src/luan/LuanException.java	Mon Aug 21 12:06:19 2017 -0600
+++ b/src/luan/LuanException.java	Thu Aug 24 14:03:36 2017 -0600
@@ -2,6 +2,7 @@
 
 import java.io.StringWriter;
 import java.io.PrintWriter;
+import java.io.PrintStream;
 import java.util.List;
 import java.util.ArrayList;
 
@@ -103,12 +104,17 @@
 		return sb.toString();
 	}
 
-	public String getLuanStackTraceString() {
+	private StringBuilder luanStackTrace() {
 		StringBuilder sb = new StringBuilder();
 		sb.append( getMessage() );
 		for( StackTraceElement ste : justLuan(getStackTrace()) ) {
 			sb.append( "\n\t" ).append( toString(ste) );
 		}
+		return sb;
+	}
+
+	public String getLuanStackTraceString() {
+		StringBuilder sb = luanStackTrace();
 		Throwable cause = getCause();
 		if( cause != null )
 			sb.append( "\nCaused by: " ).append( getJavaStackTraceString(cause) );
@@ -121,4 +127,18 @@
 		return st.isEmpty() ? null : st.get(0).getFileName();
 	}
 
+	@Override public void printStackTrace(PrintStream s) {
+		s.print("Luan: ");
+		s.println(luanStackTrace());
+		s.print("Caused by: ");
+		super.printStackTrace(s);
+	}
+
+	@Override public void printStackTrace(PrintWriter s) {
+		s.print("Luan: ");
+		s.println(luanStackTrace());
+		s.print("Caused by: ");
+		super.printStackTrace(s);
+	}
+
 }