Class SocketExceptionHelper


  • public final class SocketExceptionHelper
    extends java.lang.Object
    The Class SocketExceptionHelper with some utility methods for better SocketExceptions or NoRouteToHostExceptions.
    Since:
    1.0 (12.05.2010)
    Author:
    oliver
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      static java.net.ConnectException getBetterConnectException​(java.net.ConnectException ex, java.lang.String host, int port)
      If the given ConnectException has only the default message ("Connection refused") this message will be enrich the message by the given hostname and port number.
      static java.net.NoRouteToHostException getBetterNoRouteToHostException​(java.net.NoRouteToHostException ex, java.lang.String host, int port)
      If the given NoRouteToHostException has only the default message ("No route to host") this message will be enrich the message by the given hostname and port number.
      static java.net.NoRouteToHostException getBetterNoRouteToHostException​(java.net.NoRouteToHostException e, java.net.URLConnection connection)
      If the given NoRouteToHostException has only the default message ("No route to host") this message will be replaced by a better one.
      static java.net.SocketException getBetterSocketException​(java.net.SocketException e, java.net.URLConnection connection)
      The given SocketException is checked if it contains the host in the error message.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Method Detail

      • getBetterNoRouteToHostException

        public static java.net.NoRouteToHostException getBetterNoRouteToHostException​(java.net.NoRouteToHostException e,
                                                                                      java.net.URLConnection connection)
        If the given NoRouteToHostException has only the default message ("No route to host") this message will be replaced by a better one.
        Parameters:
        e - the original NoRouteToHostException
        connection - the connection
        Returns:
        a NoRouteToHostException which contains the host name or address
      • getBetterNoRouteToHostException

        public static java.net.NoRouteToHostException getBetterNoRouteToHostException​(java.net.NoRouteToHostException ex,
                                                                                      java.lang.String host,
                                                                                      int port)
        If the given NoRouteToHostException has only the default message ("No route to host") this message will be enrich the message by the given hostname and port number.
        Parameters:
        ex - the ex
        host - the host
        port - the port
        Returns:
        the better no route to host exception
        Since:
        1.2.10-YEARS
      • getBetterConnectException

        public static java.net.ConnectException getBetterConnectException​(java.net.ConnectException ex,
                                                                          java.lang.String host,
                                                                          int port)
        If the given ConnectException has only the default message ("Connection refused") this message will be enrich the message by the given hostname and port number.
        Parameters:
        ex - the ex
        host - the host
        port - the port
        Returns:
        the better exception
        Since:
        1.2.10-YEARS
      • getBetterSocketException

        public static java.net.SocketException getBetterSocketException​(java.net.SocketException e,
                                                                        java.net.URLConnection connection)
        The given SocketException is checked if it contains the host in the error message. If not it is appended.
        Parameters:
        e - the original SocketException
        connection - the URLConnection
        Returns:
        a better SocketException if in the original the host is missing