Skip to content

Commit bf32785

Browse files
remeiosimonbasle
authored andcommitted
Include actual cause's message in various parsing exception messages
This change improves the message of several parsing-related exceptions that would previously entirely swallow the original exception's message and sometimes have a slightly misleading message as a result. This is done by appending the cause's `toString` representation to the IllegalArgumentException messages instead of an hardcoded "cause". Closes gh-32636
1 parent 3971632 commit bf32785

File tree

2 files changed

+4
-4
lines changed

2 files changed

+4
-4
lines changed

Diff for: spring-context/src/main/java/org/springframework/scheduling/annotation/ScheduledAnnotationBeanPostProcessor.java

+3-3
Original file line numberDiff line numberDiff line change
@@ -411,7 +411,7 @@ private void processScheduledTask(Scheduled scheduled, Runnable runnable, Method
411411
}
412412
catch (RuntimeException ex) {
413413
throw new IllegalArgumentException(
414-
"Invalid initialDelayString value \"" + initialDelayString + "\" - cannot parse into long");
414+
"Invalid initialDelayString value \"" + initialDelayString + "\"; " + ex);
415415
}
416416
}
417417
}
@@ -463,7 +463,7 @@ private void processScheduledTask(Scheduled scheduled, Runnable runnable, Method
463463
}
464464
catch (RuntimeException ex) {
465465
throw new IllegalArgumentException(
466-
"Invalid fixedDelayString value \"" + fixedDelayString + "\" - cannot parse into long");
466+
"Invalid fixedDelayString value \"" + fixedDelayString + "\"; " + ex);
467467
}
468468
tasks.add(this.registrar.scheduleFixedDelayTask(new FixedDelayTask(runnable, fixedDelay, delayToUse)));
469469
}
@@ -489,7 +489,7 @@ private void processScheduledTask(Scheduled scheduled, Runnable runnable, Method
489489
}
490490
catch (RuntimeException ex) {
491491
throw new IllegalArgumentException(
492-
"Invalid fixedRateString value \"" + fixedRateString + "\" - cannot parse into long");
492+
"Invalid fixedRateString value \"" + fixedRateString + "\"; " + ex);
493493
}
494494
tasks.add(this.registrar.scheduleFixedRateTask(new FixedRateTask(runnable, fixedRate, delayToUse)));
495495
}

Diff for: spring-tx/src/main/java/org/springframework/transaction/interceptor/DefaultTransactionAttribute.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -207,7 +207,7 @@ public void resolveAttributeStrings(@Nullable StringValueResolver resolver) {
207207
}
208208
catch (RuntimeException ex) {
209209
throw new IllegalArgumentException(
210-
"Invalid timeoutString value \"" + timeoutString + "\" - cannot parse into int");
210+
"Invalid timeoutString value \"" + timeoutString + "\"; " + ex);
211211
}
212212
}
213213
}

0 commit comments

Comments
 (0)