diff --git a/spring-test/src/main/java/org/springframework/test/util/JsonPathExpectationsHelper.java b/spring-test/src/main/java/org/springframework/test/util/JsonPathExpectationsHelper.java index f6b44fdaeb5..3bb3e49c88b 100644 --- a/spring-test/src/main/java/org/springframework/test/util/JsonPathExpectationsHelper.java +++ b/spring-test/src/main/java/org/springframework/test/util/JsonPathExpectationsHelper.java @@ -237,22 +237,22 @@ public class JsonPathExpectationsHelper { } private Object evaluateJsonPath(String content) { - String message = "No value at JSON path \"" + this.expression + "\", exception: "; + String message = "No value at JSON path \"" + this.expression + "\""; try { return this.jsonPath.read(content); } catch (Throwable ex) { - throw new AssertionError(message + ex.getMessage()); + throw new AssertionError(message, ex); } } private Object evaluateJsonPath(String content, Class targetType) { - String message = "No value at JSON path \"" + this.expression + "\", exception: "; + String message = "No value at JSON path \"" + this.expression + "\""; try { return JsonPath.parse(content).read(this.expression, targetType); } catch (Throwable ex) { - throw new AssertionError(message + ex.getMessage()); + throw new AssertionError(message, ex); } } diff --git a/spring-test/src/main/java/org/springframework/test/web/client/match/ContentRequestMatchers.java b/spring-test/src/main/java/org/springframework/test/web/client/match/ContentRequestMatchers.java index 25d66f8846a..7961c943e83 100644 --- a/spring-test/src/main/java/org/springframework/test/web/client/match/ContentRequestMatchers.java +++ b/spring-test/src/main/java/org/springframework/test/web/client/match/ContentRequestMatchers.java @@ -223,7 +223,7 @@ public class ContentRequestMatchers { matchInternal(mockRequest); } catch (Exception ex) { - throw new AssertionError("Failed to parse expected or actual XML request content: " + ex.getMessage()); + throw new AssertionError("Failed to parse expected or actual XML request content", ex); } } diff --git a/spring-test/src/main/java/org/springframework/test/web/client/match/JsonPathRequestMatchers.java b/spring-test/src/main/java/org/springframework/test/web/client/match/JsonPathRequestMatchers.java index f308ddc796d..272e926c9bc 100644 --- a/spring-test/src/main/java/org/springframework/test/web/client/match/JsonPathRequestMatchers.java +++ b/spring-test/src/main/java/org/springframework/test/web/client/match/JsonPathRequestMatchers.java @@ -252,7 +252,7 @@ public class JsonPathRequestMatchers { matchInternal(mockRequest); } catch (ParseException ex) { - throw new AssertionError("Failed to parse JSON request content: " + ex.getMessage()); + throw new AssertionError("Failed to parse JSON request content", ex); } } diff --git a/spring-test/src/main/java/org/springframework/test/web/client/match/XpathRequestMatchers.java b/spring-test/src/main/java/org/springframework/test/web/client/match/XpathRequestMatchers.java index 2316714bc0b..49255719de8 100644 --- a/spring-test/src/main/java/org/springframework/test/web/client/match/XpathRequestMatchers.java +++ b/spring-test/src/main/java/org/springframework/test/web/client/match/XpathRequestMatchers.java @@ -194,7 +194,7 @@ public class XpathRequestMatchers { matchInternal(mockRequest); } catch (Exception ex) { - throw new AssertionError("Failed to parse XML request content: " + ex.getMessage()); + throw new AssertionError("Failed to parse XML request content", ex); } } diff --git a/spring-test/src/main/java/org/springframework/test/web/servlet/result/JsonPathResultMatchers.java b/spring-test/src/main/java/org/springframework/test/web/servlet/result/JsonPathResultMatchers.java index f572a372bfc..59f3d589d5e 100644 --- a/spring-test/src/main/java/org/springframework/test/web/servlet/result/JsonPathResultMatchers.java +++ b/spring-test/src/main/java/org/springframework/test/web/servlet/result/JsonPathResultMatchers.java @@ -258,9 +258,8 @@ public class JsonPathResultMatchers { MatcherAssert.assertThat(reason, content, StringStartsWith.startsWith(this.prefix)); return content.substring(this.prefix.length()); } - catch (StringIndexOutOfBoundsException oobe) { - throw new AssertionError( - "JSON prefix \"" + this.prefix + "\" not found, exception: " + oobe.getMessage()); + catch (StringIndexOutOfBoundsException ex) { + throw new AssertionError("JSON prefix \"" + this.prefix + "\" not found", ex); } } else {