diff --git a/src/main/java/net/kemitix/text/fit/BoxFitterImpl.java b/src/main/java/net/kemitix/text/fit/BoxFitterImpl.java index 2606b8d..edc09e4 100644 --- a/src/main/java/net/kemitix/text/fit/BoxFitterImpl.java +++ b/src/main/java/net/kemitix/text/fit/BoxFitterImpl.java @@ -44,7 +44,7 @@ class BoxFitterImpl implements BoxFitter { new FitEnvironment(text, fontFactory, graphics2D, boxes)); if (fit <= 2) { - throw new IllegalArgumentException("The text is too long to fit"); + throw new NotEnoughSpace(0); } return fit; } diff --git a/src/test/java/net/kemitix/text/fit/BoxFitterTest.java b/src/test/java/net/kemitix/text/fit/BoxFitterTest.java index 5f39e9a..0db6b55 100644 --- a/src/test/java/net/kemitix/text/fit/BoxFitterTest.java +++ b/src/test/java/net/kemitix/text/fit/BoxFitterTest.java @@ -89,11 +89,11 @@ public class BoxFitterTest } @Test - @DisplayName("Text too long to fit throws and exception") + @DisplayName("Text too long to fit throws") // too long to fit means it would need to be rendered at a font size of <2 public void tooLongThrows() { String longText = longStringGenerator(197); - assertThatExceptionOfType(IllegalArgumentException.class) + assertThatExceptionOfType(NotEnoughSpace.class) .isThrownBy(() -> fit(longText)); }