add ID to exception message

This commit is contained in:
Carsten Otto
2021-12-26 11:55:24 +01:00
parent f84a9174d7
commit 8ef3436f96
2 changed files with 6 additions and 6 deletions

View File

@@ -15,7 +15,7 @@ public final class ChannelId implements Comparable<ChannelId> {
public static ChannelId fromShortChannelId(long shortChannelId) {
if (shortChannelId < NOT_BEFORE) {
throw new IllegalArgumentException("Illegal channel ID");
throw new IllegalArgumentException("Illegal channel ID " + shortChannelId);
}
return new ChannelId(shortChannelId);
}

View File

@@ -11,7 +11,7 @@ import static org.assertj.core.api.Assertions.assertThatIllegalArgumentException
class ChannelIdTest {
private static final String ILLEGAL_CHANNEL_ID = "Illegal channel ID";
private static final String ILLEGAL_CHANNEL_ID = "Illegal channel ID ";
private static final String UNEXPECTED_FORMAT = "Unexpected format for compact channel ID";
@Nested
@@ -28,7 +28,7 @@ class ChannelIdTest {
void before_2016() {
assertThatIllegalArgumentException().isThrownBy(
() -> ChannelId.fromCompactForm("391176:999:999")
).withMessage(ILLEGAL_CHANNEL_ID);
).withMessageStartingWith(ILLEGAL_CHANNEL_ID);
}
@Test
@@ -70,21 +70,21 @@ class ChannelIdTest {
void negative() {
assertThatIllegalArgumentException().isThrownBy(
() -> ChannelId.fromShortChannelId(-1L)
).withMessage(ILLEGAL_CHANNEL_ID);
).withMessageStartingWith(ILLEGAL_CHANNEL_ID);
}
@Test
void zero() {
assertThatIllegalArgumentException().isThrownBy(
() -> ChannelId.fromShortChannelId(0L)
).withMessage(ILLEGAL_CHANNEL_ID);
).withMessageStartingWith(ILLEGAL_CHANNEL_ID);
}
@Test
void before_2016() {
assertThatIllegalArgumentException().isThrownBy(
() -> ChannelId.fromShortChannelId(430_103_660_018_532_351L)
).withMessage(ILLEGAL_CHANNEL_ID);
).withMessageStartingWith(ILLEGAL_CHANNEL_ID);
}
@Test