File tree Expand file tree Collapse file tree 2 files changed +17
-2
lines changed
main/java/com/typesafe/config/impl
test/scala/com/typesafe/config/impl Expand file tree Collapse file tree 2 files changed +17
-2
lines changed Original file line number Diff line number Diff line change @@ -121,6 +121,10 @@ static private class Problem extends Token {
121121 this .cause = cause ;
122122 }
123123
124+ String what () {
125+ return what ;
126+ }
127+
124128 String message () {
125129 return message ;
126130 }
@@ -139,6 +143,9 @@ public String toString() {
139143 sb .append ('\'' );
140144 sb .append (what );
141145 sb .append ('\'' );
146+ sb .append (" (" );
147+ sb .append (message );
148+ sb .append (")" );
142149 return sb .toString ();
143150 }
144151
@@ -276,6 +283,14 @@ static boolean isProblem(Token token) {
276283 return token instanceof Problem ;
277284 }
278285
286+ static String getProblemWhat (Token token ) {
287+ if (token instanceof Problem ) {
288+ return ((Problem ) token ).what ();
289+ } else {
290+ throw new ConfigException .BugOrBroken ("tried to get problem what from " + token );
291+ }
292+ }
293+
279294 static String getProblemMessage (Token token ) {
280295 if (token instanceof Problem ) {
281296 return ((Problem ) token ).message ();
Original file line number Diff line number Diff line change @@ -229,9 +229,9 @@ class TokenizerTest extends TestUtils {
229229 val problem = tokenized(1 )
230230 assertTrue(" reserved char is a problem" , Tokens .isProblem(problem))
231231 if (invalid == '+' )
232- assertEquals(" ' end of file' " , problem.toString( ))
232+ assertEquals(" end of file" , Tokens .getProblemWhat(problem ))
233233 else
234- assertEquals(" ' " + invalid + " ' " , problem.toString( ))
234+ assertEquals(" " + invalid, Tokens .getProblemWhat(problem ))
235235 }
236236 }
237237}
You can’t perform that action at this time.
0 commit comments