Exemplo n.º 1
0
 /**
  * Returns a more user-friendly error message for the specified exception.
  *
  * @param ex throwable reference
  * @return error message
  */
 public static String message(final Throwable ex) {
   debug(ex);
   if (ex instanceof BindException) return SRV_RUNNING;
   if (ex instanceof LoginException) return ACCESS_DENIED;
   if (ex instanceof ConnectException) return CONNECTION_ERROR;
   if (ex instanceof SocketTimeoutException) return TIMEOUT_EXCEEDED;
   if (ex instanceof SocketException) return CONNECTION_ERROR;
   String msg = ex.getMessage();
   if (msg == null || msg.isEmpty()) msg = ex.toString();
   if (ex instanceof FileNotFoundException) return info(RES_NOT_FOUND_X, msg);
   if (ex instanceof UnknownHostException) return info(UNKNOWN_HOST_X, msg);
   return msg;
 }