diff options
Diffstat (limited to 'src/main/java/org/zwobble/mammoth')
3 files changed, 12 insertions, 5 deletions
diff --git a/src/main/java/org/zwobble/mammoth/internal/styles/parsing/DocumentMatcherParser.java b/src/main/java/org/zwobble/mammoth/internal/styles/parsing/DocumentMatcherParser.java index 0998f8b..368bc81 100644 --- a/src/main/java/org/zwobble/mammoth/internal/styles/parsing/DocumentMatcherParser.java +++ b/src/main/java/org/zwobble/mammoth/internal/styles/parsing/DocumentMatcherParser.java @@ -29,7 +29,7 @@ public class DocumentMatcherParser { case "strike": return StyleMapBuilder::strikethrough; default: - throw new IllegalArgumentException("Unrecognised document element: " + identifier); + throw new ParseException("Unrecognised document element: " + identifier); } } @@ -88,7 +88,7 @@ public class DocumentMatcherParser { } else if (listType.equals("unordered-list")) { return false; } else { - throw new IllegalArgumentException("Unrecognised list type: " + listType); + throw new ParseException("Unrecognised list type: " + listType); } } } diff --git a/src/main/java/org/zwobble/mammoth/internal/styles/parsing/ParseException.java b/src/main/java/org/zwobble/mammoth/internal/styles/parsing/ParseException.java new file mode 100644 index 0000000..718bb30 --- /dev/null +++ b/src/main/java/org/zwobble/mammoth/internal/styles/parsing/ParseException.java @@ -0,0 +1,7 @@ +package org.zwobble.mammoth.internal.styles.parsing; + +public class ParseException extends RuntimeException { + public ParseException(String message) { + super(message); + } +} diff --git a/src/main/java/org/zwobble/mammoth/internal/styles/parsing/TokenIterator.java b/src/main/java/org/zwobble/mammoth/internal/styles/parsing/TokenIterator.java index df22b5d..f006007 100644 --- a/src/main/java/org/zwobble/mammoth/internal/styles/parsing/TokenIterator.java +++ b/src/main/java/org/zwobble/mammoth/internal/styles/parsing/TokenIterator.java @@ -46,12 +46,12 @@ public class TokenIterator { } String actualValue = tokens.get(index).getValue(); if (!actualValue.equals(tokenValue)) { - throw new IllegalArgumentException("expected " + tokenType + " token with value " + tokenValue + " but value was " + actualValue); + throw new ParseException("expected " + tokenType + " token with value " + tokenValue + " but value was " + actualValue); } index += 1; } - private IllegalArgumentException unexpectedTokenType(TokenType expected, TokenType actual) { - return new IllegalArgumentException("expected token of type " + expected + " but was of type " + actual); + private ParseException unexpectedTokenType(TokenType expected, TokenType actual) { + return new ParseException("expected token of type " + expected + " but was of type " + actual); } } |
