-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCompilationException.java
More file actions
39 lines (32 loc) · 929 Bytes
/
Copy pathCompilationException.java
File metadata and controls
39 lines (32 loc) · 929 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
/**
*
* compilation exception analyser for 312 exercise.
*
* This class has been provided to students
*
* @Author: Roger Garside, John Mariani, John Vidler, Paul Rayson
*
*
**/
public class CompilationException extends Exception
{
private static final int MAX_TRACE_DEPTH = 20;
public CompilationException( String message ) {
super( message );
}
public CompilationException( String message, CompilationException cause ) {
super( message, cause );
}
public String toTraceString() {
StringBuffer buffer = new StringBuffer();
Throwable err = this;
int maxDepth = MAX_TRACE_DEPTH;
while( err != null && maxDepth-- > 0 ) {
buffer.append( "\tCaused by " ).append( err.getMessage() ).append( "\r\n" );
err = err.getCause();
}
if( maxDepth < 1 )
buffer.append( "\t ... etc.\r\n" );
return buffer.toString();
}
} // end of class CompilationException