Java Network Interface Get getNetworkErrorMessage(Throwable e)

Here you can find the source of getNetworkErrorMessage(Throwable e)

Description

get Network Error Message

License

Open Source License

Declaration

public static String getNetworkErrorMessage(Throwable e) 

Method Source Code

//package com.java2s;
/*/*from w  w  w.  j  a  va2  s . c o m*/
 * FindBugs - Find Bugs in Java programs
 * Copyright (C) 2006, University of Maryland
 *
 * This library is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Lesser General Public
 * License as published by the Free Software Foundation; either
 * version 2.1 of the License, or (at your option) any later version.
 *
 * This library is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 * Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public
 * License along with this library; if not, write to the Free Software
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 */

import java.net.UnknownHostException;

public class Main {
    public static String getNetworkErrorMessage(Throwable e) {
        if ("InvalidProtocolBufferException".equals(e.getClass()
                .getSimpleName())) {
            return "Your Internet provider may require you to log in via your web browser.";
        }
        if (e instanceof UnknownHostException) {
            return "You may not be connected to the Internet.";
        } else {
            return e.getClass().getSimpleName() + ": " + e.getMessage();
        }
    }
}

Related

  1. getLoopbackInterface()
  2. getLoopbackInterfaceName()
  3. getLoopbackNIF()
  4. getMac()
  5. getMacBytes()
  6. getNetworkInterface()
  7. getNetworkInterface()
  8. getNetworkInterface(String name)
  9. getNetworkInterfaceArray(String name)