diff --git a/lib/src/main/java/com/auth0/jwt/impl/JWTParser.java b/lib/src/main/java/com/auth0/jwt/impl/JWTParser.java index 1efb825e..45854785 100644 --- a/lib/src/main/java/com/auth0/jwt/impl/JWTParser.java +++ b/lib/src/main/java/com/auth0/jwt/impl/JWTParser.java @@ -49,14 +49,17 @@ static ObjectMapper getDefaultObjectMapper() { @SuppressWarnings("WeakerAccess") T convertFromJSON(String json, Class tClazz) throws JWTDecodeException { - JWTDecodeException exception = new JWTDecodeException(String.format("The string '%s' doesn't have a valid JSON format.", json)); if (json == null) { - throw exception; + throw exceptionForInvalidJson(null); } try { return mapper.readValue(json, tClazz); } catch (IOException e) { - throw exception; + throw exceptionForInvalidJson(json); } } + + private JWTDecodeException exceptionForInvalidJson(String json) { + return new JWTDecodeException(String.format("The string '%s' doesn't have a valid JSON format.", json)); + } }