Lines 18-23
Link Here
|
18 |
import java.io.IOException; |
18 |
import java.io.IOException; |
19 |
import java.io.InputStream; |
19 |
import java.io.InputStream; |
20 |
import java.io.InputStreamReader; |
20 |
import java.io.InputStreamReader; |
|
|
21 |
import java.io.PrintWriter; |
22 |
import java.io.StringWriter; |
21 |
import java.io.UnsupportedEncodingException; |
23 |
import java.io.UnsupportedEncodingException; |
22 |
import java.util.StringTokenizer; |
24 |
import java.util.StringTokenizer; |
23 |
import java.util.zip.ZipEntry; |
25 |
import java.util.zip.ZipEntry; |
Lines 427-432
Link Here
|
427 |
return contents; |
429 |
return contents; |
428 |
} |
430 |
} |
429 |
|
431 |
|
|
|
432 |
/** |
433 |
* Returns a one line summary for an exception (extracted from its stacktrace: name + first frame) |
434 |
* @param exception |
435 |
* @return one line summary for an exception |
436 |
*/ |
437 |
public static String getExceptionSummary(Throwable exception) { |
438 |
StringWriter stringWriter = new StringWriter(); |
439 |
exception.printStackTrace(new PrintWriter(stringWriter)); |
440 |
StringBuffer buffer = stringWriter.getBuffer(); |
441 |
StringBuffer exceptionBuffer = new StringBuffer(50); |
442 |
exceptionBuffer.append(exception.toString()); |
443 |
// only keep leading frame portion of the trace (i.e. line no. 2 from the stacktrace) |
444 |
lookupLine2: for (int i = 0, lineSep = 0, max = buffer.length(), line2Start = 0; i < max; i++) { |
445 |
switch (buffer.charAt(i)) { |
446 |
case '\n': |
447 |
case '\r' : |
448 |
if (line2Start > 0) { |
449 |
exceptionBuffer.append(' ').append(buffer.substring(line2Start, i)); |
450 |
break lookupLine2; |
451 |
} |
452 |
lineSep++; |
453 |
break; |
454 |
case ' ' : |
455 |
case '\t' : |
456 |
break; |
457 |
default : |
458 |
if (lineSep > 0) { |
459 |
line2Start = i; |
460 |
lineSep = 0; |
461 |
} |
462 |
break; |
463 |
} |
464 |
} |
465 |
return exceptionBuffer.toString(); |
466 |
} |
467 |
|
430 |
public static int getLineNumber(int position, int[] lineEnds, int g, int d) { |
468 |
public static int getLineNumber(int position, int[] lineEnds, int g, int d) { |
431 |
if (lineEnds == null) |
469 |
if (lineEnds == null) |
432 |
return 1; |
470 |
return 1; |