@@ -107,19 +107,41 @@ void failsWithCorrectTraceWithExFailureInThat() {
107107 "Take error message from 'otherwise', not from original error" ,
108108 Assertions .assertThrows (
109109 ExFailure .class ,
110- () -> new Expect <>("something" , () -> 42.2 )
111- .must (i -> i > 0 )
112- .otherwise ("must be positive" )
110+ () -> new Expect <>("attr" , () -> 42.2 )
113111 .that (
114112 i -> {
115- throw new ExFailure ("some error" );
113+ throw new ExFailure ("Some error in operation " );
116114 }
117115 )
118- .otherwise ("something went wrong" )
116+ .otherwise ("must be converted to something" )
117+ .it (),
118+ "fails on 'that' because of some internal error"
119+ ).getMessage (),
120+ Matchers .equalTo ("attr must be converted to something" )
121+ );
122+ }
123+
124+ @ Test
125+ void failsWithCorrectTraceWithExFailureInThatForParsing () {
126+ MatcherAssert .assertThat (
127+ "Take error message from 'otherwise', not from original error" ,
128+ Assertions .assertThrows (
129+ ExFailure .class ,
130+ () -> new Expect <>("attr" , () -> "string" )
131+ .that (
132+ i -> {
133+ try {
134+ return Integer .parseInt (i );
135+ } catch (final NumberFormatException ex ) {
136+ throw new ExFailure ("Can't parse to integer" , ex );
137+ }
138+ }
139+ )
140+ .otherwise ("must be an integer" )
119141 .it (),
120- "fails on 'that'"
142+ "fails on 'that' because can not parse "
121143 ).getMessage (),
122- Matchers .equalTo ("something went wrong " )
144+ Matchers .equalTo ("attr must be an integer " )
123145 );
124146 }
125147}
0 commit comments