Attempt to diagnose Equinox exceptions and issue a sane error message rather than a massive equinox stack

@param ex The RuntimeException thrown by Equinox
@return true if we understand the exception and issued an error message, false otherwise
343612
private boolean handleEquinoxRuntimeException(RuntimeException ex) {

        Throwable cause = ex.getCause();
        if (cause != null) {
            if (cause instanceof IOException) {
                // Check common causes for IOExceptions
                File osgiDir = config.getWorkareaFile(OSGI_DIR_NAME);
                if (!osgiDir.exists() || !osgiDir.isDirectory() || !osgiDir.canWrite()) {
                    Tr.error(tc, "error.serverDirPermission", osgiDir.getAbsolutePath());
                    return true;
                }
                File managerDir = new File(osgiDir, MANAGER_DIR_NAME);
                if (!managerDir.exists() || !managerDir.isDirectory() || !managerDir.canWrite()) {
                    Tr.error(tc, "error.serverDirPermission", managerDir.getAbsolutePath());
                    return true;
                }

            }

        }
        return false;
    }
1152030
void internalPropagateException(Throwable ex) {
    CountedCompleter<?> a = this, s = a;
    while (a.onExceptionalCompletion(ex, s) && (a = (s = a).completer) != null && a.status >= 0
        && a.recordExceptionalCompletion(ex) == EXCEPTIONAL);
  }
1141664
public static String getMessage( final Throwable    ex )
    {
        String      message = ex.getMessage();

        //
        //    It *appears* as though the SQLException hasn't been
        //    converted to nest?  It seems like it has it's own
        //    method of nesting, not sure why.  I don't know
        //    why Sun wouldn't have converted it.  Maybe they
        //    did, but just left these getNextException methods
        //    on for compatibility?   In my java source code, they
        //    aren't deprecated, though.
        //
        if ( ex instanceof SQLException )
        {
            String    sqlMessage = getSqlExceptionMessage( (SQLException) ex );
            if ( ! StringUtils.isBlank( sqlMessage ) )
            {
                if ( ! StringUtils.isBlank( message ) )
                {
                    message  += "\n" + sqlMessage;
                }
                else
                {
                    message = sqlMessage;
                }
            }
        }


        Throwable    cause = ex.getCause();

        if ( ex instanceof SamSixException
             && ((SamSixException) ex).isShowThisCauseOnly() )
        {
            return message;
        }

        if ( cause != null )
        {
            String causeMessage = ExceptionUtils.getMessage( cause );

            if ( ! StringUtils.isBlank( causeMessage ) )
            {
                if ( ! StringUtils.isBlank( message ) )
                {
                    //
                    //    ALWAYS use "broadest first" when showing error messages.
                    //    Otherwise, error messages end up with some non-human readable thing at the top,
                    //    confusing users with deeply technical details. This is especially important for user errors.
                    //
                    //    broadest/non-broadest should be used for stack traces only.
                    //

                    message = message + "\n" + causeMessage;
                }
                else
                {
                    message = causeMessage;
                }
            }
        }


        if ( ! StringUtils.isBlank( message ) )
        {
            return message;
        }

        return ex.getClass().getName() + ":  An error has been detected.";
    }
1117484
def ep(self, exc: Exception) -> bool:
        """"""
        if not isinstance(exc, ConnectionAbortedError):
            return False

        if len(exc.args) != 2:
            return False

        origin, reason = exc.args

        logging.getLogger(__name__).warning('Exited')

        return True
1122015
public synchronized boolean fail(ServiceException ex) {
        if (completed) {
            return false;
        }
        this.completed = true;
        this.ex = ex;
        notifyAll();
        return true;
    }
802199
public void setMessageException(Throwable ex)
    {
        String strErrorMessage = ex.getMessage();
        BaseMessage message = this.getMessage();
        if ((message != null) && (message.getMessageHeader() instanceof TrxMessageHeader))
            ((TrxMessageHeader)message.getMessageHeader()).put(TrxMessageHeader.MESSAGE_ERROR, strErrorMessage);
        else
            ex.printStackTrace();
    }
345185
public static void exit(final int exitCode, final Exception ex) {
        System.err.println(JPService.getApplicationName() + " crashed...");
        ExceptionPrinter.printHistory(ex, System.err);
        System.exit(exitCode);
    }
333901
public static function isTotpException(EntityException $e)
    {
        if (in_array($e->getStatusCode(), array(RestStatusCodesInterface::REST_CLIENT_ERROR_UNPROCESSABLE_ENTITY, RestStatusCodesInterface::REST_CLIENT_ERROR_LOCKED))
            && in_array($e->getJsonErrorCode(), self::getVerificationJsonStatusCodes())
        ) {
            return true;
        } else {
            return false;
        }
    }
551129
public boolean execute() throws SQLException {
        boolean isExceptionThrown = ExecutorExceptionHandler.isExceptionThrown();
        SQLExecuteCallback<Boolean> executeCallback = SQLExecuteCallbackFactory.getPreparedSQLExecuteCallback(getDatabaseType(), isExceptionThrown);
        List<Boolean> result = executeCallback(executeCallback);
        if (null == result || result.isEmpty() || null == result.get(0)) {
            return false;
        }
        return result.get(0);
    }
70442
static DnsException translateAndThrow(RetryHelperException ex) {
    BaseServiceException.translate(ex);
    throw new DnsException(UNKNOWN_CODE, ex.getMessage(), ex.getCause());
  }
194405
public static boolean isRetryable(KeeperException e) {
    Objects.requireNonNull(e);

    switch (e.code()) {
      case CONNECTIONLOSS:
      case SESSIONEXPIRED:
      case SESSIONMOVED:
      case OPERATIONTIMEOUT:
        return true;

      case RUNTIMEINCONSISTENCY:
      case DATAINCONSISTENCY:
      case MARSHALLINGERROR:
      case BADARGUMENTS:
      case NONODE:
      case NOAUTH:
      case BADVERSION:
      case NOCHILDRENFOREPHEMERALS:
      case NODEEXISTS:
      case NOTEMPTY:
      case INVALIDCALLBACK:
      case INVALIDACL:
      case AUTHFAILED:
      case UNIMPLEMENTED:

      // These two should not be encountered - they are used internally by ZK to specify ranges
      case SYSTEMERROR:
      case APIERROR:

      case OK: // This is actually an invalid ZK exception code

      default:
        return false;
    }
  }
310726
public static function printException(\Exception $ex)
    {
        $msg="code:".$ex->getCode()
            ."\r\nmessage:".$ex->getMessage()
            ."\r\ntrace:".$ex->getTraceAsString();
        self::printLine($msg);
    }
547407
private NaaccrIOException convertSyntaxException(ConversionException ex) {
        String msg = ex.get("message");

        // reading a file that has bad tags is very common, so let's try to get a better error message in that case:
        if (CannotResolveClassException.class.getName().equals(ex.get("cause-exception")))
            msg = "invalid tag: " + ex.get("cause-message");
        else if (StreamException.class.getName().equals(ex.get("cause-exception")))
            msg = "invalid XML syntax";

        if (msg == null)
            msg = ex.getMessage();

        NaaccrIOException e = new NaaccrIOException(msg, ex);
        if (ex.get("line number") != null)
            e.setLineNumber(Integer.valueOf(ex.get("line number")));
        e.setPath(ex.get("path"));
        return e;
    }
681927
private function handleInternalException(\Exception $ex)
    {
        $response = null;

        if ($ex instanceof ResponseAwareExceptionInterface) {
            $response = $ex->getResponse();
        }

        if ($ex instanceof ServerStopExceptionInterface) {
            $this->stopServerByException($ex);
        }

        return $response;
    }
182602
public static boolean handleCommonError(Throwable ex, String action)
  {
    if(ex != null)
    {
      Throwable rootCause = ex;
      while(rootCause.getCause() != null)
      {
        rootCause = rootCause.getCause();
      }

      if(rootCause instanceof UniformInterfaceException)
      {
        UniformInterfaceException uniEx = (UniformInterfaceException) rootCause;
        
        if(uniEx.getResponse() != null)
        {
          if(uniEx.getResponse().getStatus() == 503)
          {
            // database connection error
            Notification n = new Notification(
                "Can't execute " + (action == null ? "" : "\"" + action + "\"" ) 
                + " action because database server is not responding.<br/>"
                + "There might be too many users using this service right now.", 
                Notification.Type.WARNING_MESSAGE);
            n.setDescription("<p><strong>Please try again later.</strong> If the error persists inform the administrator of this server.</p>"
                + "<p>Click on this message to close it.</p>"
                + "<p style=\"font-size:9pt;color:gray;\">Pinguin picture by Polar Cruises [CC BY 2.0 (http://creativecommons.org/licenses/by/2.0)], via Wikimedia Commons</p>");
            n.setIcon(PINGUIN_IMAGE);
            n.setHtmlContentAllowed(true);
            n.setDelayMsec(15000);
           
            n.show(Page.getCurrent());
            
            return true;
          }
        }
       
      }
    }
    return false;
  }
221040
public static ErrorDescription create(ApplicationException ex) {
    	ErrorDescription description = new ErrorDescription();
    	description.setCategory(ex.getCategory());
    	description.setStatus(ex.getStatus());
    	description.setCode(ex.getCode());
    	description.setMessage(ex.getMessage());
    	description.setDetails(ex.getDetails());
    	description.setCorrelationId(ex.getCorrelationId());    	
    	description.setCause(ex.getCauseString());    	
    	description.setStackTrace(ex.getStackTraceString());    	
    	return description;
    }
967575
public static RuntimeException getRuntimeException(final Throwable exc) {
        Throwable e = exc;
        while (e.getCause() instanceof RuntimeException) {
            e = e.getCause();
        }
        if (e instanceof RuntimeException) {
            return (RuntimeException) e;
        } else {
            return new RuntimeException(exc);
        }
    }