From 8c87bae9734b206c5cee74f736c94a9e60dae94f Mon Sep 17 00:00:00 2001 From: Jani Simomaa Date: Tue, 23 May 2017 16:09:48 +0300 Subject: [PATCH] Add ParseException.getMessage() Overriding getMessage() in order to prevent cases where `detailMessage = null` in order to provide descriptive messages --- .../github/zafarkhaja/semver/ParseException.java | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/src/main/java/com/github/zafarkhaja/semver/ParseException.java b/src/main/java/com/github/zafarkhaja/semver/ParseException.java index 6596b87..4e77495 100644 --- a/src/main/java/com/github/zafarkhaja/semver/ParseException.java +++ b/src/main/java/com/github/zafarkhaja/semver/ParseException.java @@ -58,6 +58,19 @@ public ParseException(String message, UnexpectedCharacterException cause) { super(message); initCause(cause); } + + /** + * Returns the message of this exception. If the message is not set, + * returns the string representation provided by toString() + * + * @return the message of this exception + */ + @Override + public String getMessage() { + if (super.getMessage() != null) + return super.getMessage(); + return toString(); + } /** * Returns the string representation of this exception.