diff options
Diffstat (limited to 'app/src/main/java/com/wireguard/config/InetAddresses.java')
-rw-r--r-- | app/src/main/java/com/wireguard/config/InetAddresses.java | 9 |
1 files changed, 5 insertions, 4 deletions
diff --git a/app/src/main/java/com/wireguard/config/InetAddresses.java b/app/src/main/java/com/wireguard/config/InetAddresses.java index 989598da..487b136c 100644 --- a/app/src/main/java/com/wireguard/config/InetAddresses.java +++ b/app/src/main/java/com/wireguard/config/InetAddresses.java @@ -37,17 +37,18 @@ public final class InetAddresses { * @param address a string representing the IP address * @return an instance of {@link Inet4Address} or {@link Inet6Address}, as appropriate */ - public static InetAddress parse(final String address) { + public static InetAddress parse(final String address) throws ParseException { if (address.isEmpty()) - throw new IllegalArgumentException("Empty address"); + throw new ParseException(InetAddress.class, address, "Empty address"); try { return (InetAddress) PARSER_METHOD.invoke(null, address); } catch (final IllegalAccessException | InvocationTargetException e) { final Throwable cause = e.getCause(); // Re-throw parsing exceptions with the original type, as callers might try to catch // them. On the other hand, callers cannot be expected to handle reflection failures. - throw cause instanceof IllegalArgumentException ? - (IllegalArgumentException) cause : new RuntimeException(e); + if (cause instanceof IllegalArgumentException) + throw new ParseException(InetAddress.class, address, cause); + throw new RuntimeException(e); } } } |