@@ -95,7 +95,7 @@ KoanSuiteResult runKoans() throws IllegalArgumentException,
9595 String message = failure != null
9696 && KoanIncompleteException .class .isAssignableFrom (failure .getClass ()) ?
9797 failure .getMessage () : formatNormalException (failure );
98- if (message != null && message .contains (EXPECTED_LEFT + __ + EXPECTED_RIGHT )) {
98+ if (failure instanceof KoanIncompleteException && message .contains (EXPECTED_LEFT + __ + EXPECTED_RIGHT )) {
9999 logExpectationOnWrongSideWarning (firstFailingSuite ,
100100 firstFailingMethod .getMethod ());
101101 }
@@ -109,7 +109,7 @@ KoanSuiteResult runKoans() throws IllegalArgumentException,
109109 }
110110
111111 private String formatNormalException (Throwable failure ) {
112- return failure == null ? "" : failure . getMessage ();
112+ return failure == null ? "" : fillStackTrace ( failure ). toString ();
113113 }
114114
115115 /**
@@ -121,23 +121,30 @@ private String formatNormalException(Throwable failure) {
121121 * @return
122122 */
123123 static String getOriginalLineNumber (Throwable t , Class <?> failingSuite ){
124- StringWriter stringWriter = new StringWriter ();
125- if (t == null ){
126- return null ;
127- }
128- t .printStackTrace (new PrintWriter (stringWriter ));
124+ StringWriter stringWriter = fillStackTrace (t );
129125 String [] lines = stringWriter .toString ().split (EOLS );
130- for (int i = lines .length - 1 ; i >= 0 ; --i ){
131- String line = lines [i ];
132- if (line .contains (failingSuite .getName ())){
133- return line .substring (
134- line .indexOf (KoanConstants .LINE_NO_START )+KoanConstants .LINE_NO_START .length (),
135- line .lastIndexOf (KoanConstants .LINE_NO_END ));
126+ if (failingSuite != null ){
127+ for (int i = lines .length - 1 ; i >= 0 ; --i ){
128+ String line = lines [i ];
129+ if (line .contains (failingSuite .getName ())){
130+ return line .substring (
131+ line .indexOf (KoanConstants .LINE_NO_START )+KoanConstants .LINE_NO_START .length (),
132+ line .lastIndexOf (KoanConstants .LINE_NO_END ));
133+ }
136134 }
137135 }
138136 return null ;
139137 }
140138
139+ private static StringWriter fillStackTrace (Throwable t ) {
140+ StringWriter stringWriter = new StringWriter ();
141+ if (t == null ){
142+ return stringWriter ;
143+ }
144+ t .printStackTrace (new PrintWriter (stringWriter ));
145+ return stringWriter ;
146+ }
147+
141148 private Path getPathToEnlightement () {
142149 if (pathToEnlightenment == null ){
143150 pathToEnlightenment = PathToEnlightenment .getPathToEnlightment ();
0 commit comments