-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathErrorManager.java
More file actions
82 lines (68 loc) · 2.23 KB
/
Copy pathErrorManager.java
File metadata and controls
82 lines (68 loc) · 2.23 KB
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
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
/**
* Display and count the errors, the warnings as well.
*/
public class ErrorManager{
private int error_count;
private int warning_count;
public ErrorManager(){
/* this.error_count = 0;
this.warning_count = 0; */
}
/**
* Just call printError with an empty option ( ie "" )
* @param source
* @param e
*/
public void printError(ErrorSource source, ErrorType e){
this.printError(source, e, "");
}
/**
* Call the print function, and increment the error count.
*
* @see print
* @param source
* @param e
* @param option
*/
public void printError(ErrorSource source, ErrorType e, String option){
this.print("Error", source, e, option);
this.error_count++;
}
/**
* Call the print function, and increment the warning count.
*
* @see print
* @param source
* @param e
* @param option
*/
public void printWarning(ErrorSource source, ErrorType e, String option){
this.print("Warning", source, e, option);
this.warning_count++;
}
/**
* Will print the error on System.err (very useful the redirect only the
* error stream.
*
* @param t The text for an error or a warning
* @param s The error source. Will use the text in the enum the print it
* @param e The error Type. Will use the message defined in the enum
* @param o The option. If "", does not print anything
*/
private void print(String t, ErrorSource s, ErrorType e, String o){
System.err.print(t + " - " + s.getMessage() + "\n");
System.err.println("* " + e.getMessage());
if(o != ""){
System.err.println("* " + o);
}
System.err.println("* " + Yaka.lineManager + "\n");
}
/**
* Just print the error and warning count.
* Called at the end of the compilation (or earlier if you have no idea what
* you're doing.
*/
public void finalPrint(){
System.err.printf("%d errors, %d warnings\n", this.error_count, this.warning_count);
}
}