1111 *
1212 * @author hexaredecimal
1313 */
14- public class PiccodeException extends RuntimeException implements PiccodeInfo {
14+ public class PiccodeWarning implements PiccodeInfo {
1515
1616 public String file ;
1717 public int line , col ;
@@ -21,8 +21,7 @@ public class PiccodeException extends RuntimeException implements PiccodeInfo {
2121
2222 private List <PiccodeInfo > notes = new ArrayList <>();
2323
24- public PiccodeException (String file , int line , int col , String message ) {
25- super (message );
24+ public PiccodeWarning (String file , int line , int col , String message ) {
2625 this .file = file ;
2726 this .line = line ;
2827 this .col = col ;
@@ -33,12 +32,12 @@ public void addNote(PiccodeInfo note) {
3332 this .notes .add (note );
3433 }
3534
36- public void reportError () {
37- reportError (! ReplState . ACTIVE , "ERROR " );
35+ public void report () {
36+ report ( false , "WARNING " );
3837 }
3938
4039 @ Override
41- public void reportError (boolean die , String kind ) {
40+ public void report (boolean die , String kind ) {
4241 var fp = new File ("" );
4342
4443 String [] lines = new String []{};
@@ -60,8 +59,8 @@ public void reportError(boolean die, String kind) {
6059 ? "repl"
6160 : fp .getName (),
6261 line , col + 1 ,
63- kind == null || kind .equals ("ERROR " )
64- ? Chalk .on ("ERROR " ).red () // I hard code ERROR just in case it is null;
62+ kind == null || kind .equals ("WARNING " )
63+ ? Chalk .on ("WARNING " ).yellow () // I hard code ERROR just in case it is null;
6564 : Chalk .on (kind .toUpperCase ()).yellow (),
6665 message
6766 );
@@ -90,41 +89,9 @@ public void reportError(boolean die, String kind) {
9089 if (!notes .isEmpty ()) {
9190 System .out .println ((Chalk .on ("." ).yellow () + "\n " ).repeat (2 ));
9291 for (var note : notes ) {
93- note .reportError (false , "INFO" );
92+ note .report (false , "INFO" );
9493 }
9594 }
96-
97- var ctx = frame == null
98- ? Context .top
99- : Context .getContextAt (frame );
100-
101- if (frame != null ) {
102- ctx = Context .getContextAt (frame );
103- }
104- var stack = ctx .getCallStack ();
105-
106- var list = List .of (stack .toArray (StackFrame []::new )).reversed ();
107-
108- if (!list .isEmpty ()) {
109- var thread = frame == null ? "" : String .format (".THREAD[%s]" , frame );
110- System .out .println ("\n [STACK TRACE]" + thread );
111- for (int i = 0 ; i < list .size (); i ++) {
112- var _frame = list .get (i );
113- var callSite = _frame .caller ;
114- var _str = String .format (
115- "[%s:%d:%d]: %s" , callSite .file ,
116- callSite .line , callSite .column + 1 ,
117- i == 0
118- ? Chalk .on (callSite .toString ()).red ()
119- : callSite .toString ());
120-
121- System .out .println (_str );
122- }
123- }
124-
125- if (die ) {
126- System .exit (1 );
127- }
12895 }
12996
13097 private static String [] toLines (File fp ) {
0 commit comments