Author: thomasobrien95
Date: Mon Dec 15 13:37:32 2008
New Revision: 2880
Modified:
trunk/src/ca/sqlpower/architect/profile/output/ProfilePDFFormat.java
Log:
Added a fix for bug 1234. Exceptions for profiling now has the first four
elements of its stack trace shown. Additionally exceptions that are
displayed in cells are no longer truncated.
Modified:
trunk/src/ca/sqlpower/architect/profile/output/ProfilePDFFormat.java
==============================================================================
--- trunk/src/ca/sqlpower/architect/profile/output/ProfilePDFFormat.java
(original)
+++ trunk/src/ca/sqlpower/architect/profile/output/ProfilePDFFormat.java
Mon Dec 15 13:37:32 2008
@@ -70,6 +70,14 @@
private static final int PIXELS_PER_BORDER = 6;
private static final Logger logger =
Logger.getLogger(ProfilePDFFormat.class);
+
+ /**
+ * The number of elements we will show in the stack trace before it is
truncated.
+ * The stack trace is truncated as long stack traces will make the
table small at
+ * the bottom of the page and require a lot more pages than normal to
print.
+ */
+ private static final int STACK_TRACE_LENGTH = 4;
+
private int totalColumn;
@@ -392,9 +400,18 @@
heading.append("Connection: ").append(sqlTable.getParentDatabase().getName()).append("\n");
heading.append("Table: ").append(ArchitectUtils.toQualifiedName(sqlTable,
SQLDatabase.class));
if ( result.getException() != null ) {
- heading.append(" Profiling Error");
- if ( result.getException() != null )
+ heading.append("\nProfiling Error");
+ if ( result.getException() != null ) {
heading.append(":\n").append(result.getException());
+ StackTraceElement[] stackTrace =
result.getException().getStackTrace();
+ for (int i = 0; i < STACK_TRACE_LENGTH && i <
stackTrace.length; i++) {
+ StackTraceElement element = stackTrace[i];
+
heading.append("\n ").append(element.getFileName()).append(".").append(element.getClassName()).append(".").append(element.getMethodName()).append("(").append(element.getLineNumber()).append(")");
+ }
+ if (stackTrace.length > STACK_TRACE_LENGTH) {
+
heading.append("\n ... ").append(stackTrace.length).append(" more");
+ }
+ }
}
else {
PdfPCell infoCell;
@@ -922,7 +939,7 @@
// update column width to reflect the widest cell
for (String contentLine : contents.split("\n")) {
String newLine;
- if (truncateLength >= 0) {
+ if (truncateLength >= 0 && !(tProfile == null ||
tProfile.getException() != null)) {
if (bf.getWidthPoint(contentLine, fsize) <
truncateLength) {
newLine = contentLine + "\n";
} else {