@@ -10,16 +10,14 @@ public class LJDiagnostic extends RuntimeException {
1010
1111 private final String title ;
1212 private final String message ;
13- private final String details ;
1413 private final String file ;
1514 private final ErrorPosition position ;
1615 private final String accentColor ;
1716
18- public LJDiagnostic (String title , String message , String details , SourcePosition pos , String accentColor ) {
17+ public LJDiagnostic (String title , String message , SourcePosition pos , String accentColor ) {
1918 this .title = title ;
2019 this .message = message ;
21- this .details = details ;
22- this .file = pos != null ? pos .getFile ().getPath () : null ;
20+ this .file = (pos != null && pos .getFile () != null ) ? pos .getFile ().getPath () : null ;
2321 this .position = ErrorPosition .fromSpoonPosition (pos );
2422 this .accentColor = accentColor ;
2523 }
@@ -33,7 +31,7 @@ public String getMessage() {
3331 }
3432
3533 public String getDetails () {
36- return details ;
34+ return "" ; // to be overridden by subclasses
3735 }
3836
3937 public ErrorPosition getPosition () {
@@ -44,13 +42,17 @@ public String getFile() {
4442 return file ;
4543 }
4644
45+ public String getAccentColor () {
46+ return accentColor ;
47+ }
48+
4749 @ Override
4850 public String toString () {
4951 StringBuilder sb = new StringBuilder ();
5052
5153 // title
52- sb .append ("\n " ).append (accentColor ).append (title ).append (": " ).append (Colors .RESET )
53- .append (message . toLowerCase ()). append ( "\n " );
54+ sb .append ("\n " ).append (accentColor ).append (title ).append (": " ).append (Colors .RESET ). append ( message )
55+ .append ("\n " );
5456
5557 // snippet
5658 String snippet = getSnippet ();
@@ -59,7 +61,8 @@ public String toString() {
5961 }
6062
6163 // details
62- if (details != null && !details .isEmpty ()) {
64+ String details = getDetails ();
65+ if (!details .isEmpty ()) {
6366 sb .append (" --> " ).append (String .join ("\n " , details .split ("\n " ))).append ("\n " );
6467 }
6568
@@ -124,7 +127,6 @@ public boolean equals(Object obj) {
124127 return false ;
125128 LJDiagnostic other = (LJDiagnostic ) obj ;
126129 return title .equals (other .title ) && message .equals (other .message )
127- && ((details == null && other .details == null ) || (details != null && details .equals (other .details )))
128130 && ((file == null && other .file == null ) || (file != null && file .equals (other .file )))
129131 && ((position == null && other .position == null )
130132 || (position != null && position .equals (other .position )));
@@ -134,7 +136,6 @@ public boolean equals(Object obj) {
134136 public int hashCode () {
135137 int result = title .hashCode ();
136138 result = 31 * result + message .hashCode ();
137- result = 31 * result + (details != null ? details .hashCode () : 0 );
138139 result = 31 * result + (file != null ? file .hashCode () : 0 );
139140 result = 31 * result + (position != null ? position .hashCode () : 0 );
140141 return result ;
0 commit comments