Create an install exception from an existing exception

@param e
@return
437354
static InstallException create(Exception e) {
        if (e instanceof ProductInfoParseException) {
            ProductInfoParseException pipe = (ProductInfoParseException) e;
            String missingKey = pipe.getMissingKey();
            if (missingKey != null) {
                return create(Messages.UTILITY_MESSAGES.getLogMessage("version.missing.key", missingKey, pipe.getFile().getAbsoluteFile()));
            }
            return create(Messages.UTILITY_MESSAGES.getLogMessage("ERROR_UNABLE_READ_FILE", pipe.getFile().getAbsoluteFile(),
                                                                  pipe.getCause().getMessage()));
        }
        if (e instanceof DuplicateProductInfoException) {
            DuplicateProductInfoException dpie = (DuplicateProductInfoException) e;
            return create(Messages.UTILITY_MESSAGES.getLogMessage("version.duplicated.productId", ProductInfo.COM_IBM_WEBSPHERE_PRODUCTID_KEY,
                                                                  dpie.getProductInfo1().getFile().getAbsoluteFile(),
                                                                  dpie.getProductInfo2().getFile().getAbsoluteFile()));
        }
        if (e instanceof ProductInfoReplaceException) {
            ProductInfoReplaceException pire = (ProductInfoReplaceException) e;
            ProductInfo productInfo = pire.getProductInfo();
            String replacesId = productInfo.getReplacesId();
            if (replacesId.equals(productInfo.getId())) {
                return create(Messages.UTILITY_MESSAGES.getLogMessage("version.replaced.product.can.not.itself", productInfo.getFile().getAbsoluteFile()));
            }
            return create(Messages.UTILITY_MESSAGES.getLogMessage("version.replaced.product.not.exist", replacesId,
                                                                  productInfo.getFile().getAbsoluteFile()));
        }
        if (e instanceof RepositoryBackendIOException) {
            return create((RepositoryException) e, new Throwable(e), (RestRepositoryConnectionProxy) null, true);
        }
        return create(e.getMessage(), e, InstallException.RUNTIME_EXCEPTION);
    }
25883
protected static StringBuilder handleExceptionStart(Exception e) {
        LOG.warning(ExceptionUtils.getStackTrace(e));
        StringBuilder sb = new StringBuilder();
        if (e.getMessage() != null) {
            sb.append(e.getMessage()).append(". ");
        }
        if (e.getCause() != null && e.getCause().getMessage() != null) {
            sb.append(e.getCause().getMessage()).append(". ");
        }
        return sb;
    }
874689
public static function fromException(\Exception $e): self
    {
        return new self($e->getMessage(), $e->getCode(), $e);
    }
980831
public static String getExceptionMessage(Exception e) {
        if (e.getCause() != null && e.getCause().getMessage() != null) {
            String s = getscard(e.getCause().getMessage());
            if (s != null)
                return s;
        }
        if (e.getMessage() != null) {
            String s = getscard(e.getMessage());
            if (s != null)
                return s;
        }
        return e.getMessage();
    }
316644
@Override
	public void setException(@NotNull Throwable e) {
		assert !isComplete();
		exception = e;
		completeExceptionally(e);
	}
1224969
public static RuntimeException handle(Throwable e) {
        if (e instanceof CRestException) {
            return handle((CRestException) e);
        }else if (e instanceof RequestException) {
            return handle((RequestException) e);
        } else if (e instanceof IllegalArgumentException) {
            return handle((IllegalArgumentException) e);
        } else if (e instanceof IllegalStateException) {
            return handle((IllegalStateException) e);
        } else if (e instanceof InvocationTargetException) {
            return handle((InvocationTargetException) e);
        } else {
            return new CRestException(e.getMessage(), e);
        }
    }
1021603
private static RuntimeException getCause(InvocationTargetException e) {
        Throwable cause = e.getCause();
        if(cause instanceof RuntimeException)
            throw (RuntimeException) cause;
        else
            throw new IllegalArgumentException(e.getCause());
    }
813782
private Map<String, javax.ejb.ApplicationException> createApplicationExceptionMap(EJBJar ejbJar) {
        final boolean isTraceOn = TraceComponent.isAnyTracingEnabled();
        if (isTraceOn && tc.isEntryEnabled())
            Tr.entry(tc, "createApplicationExceptionMap : " + ejbJar);

        // Get List of ApplicationException objects and convert to a Map where
        // key is String name of exceptions class and value is the rollback
        // setting of the exception class from xml.
        // d541552, d541552.1 - Improve performance and footprint.  Returned
        //                      exceptionMap in MDO may be null (ie. the
        //                      map is only created when it is needed).
        if (ejbJar != null) {
            AssemblyDescriptor assemblyDescriptor = ejbJar.getAssemblyDescriptor();
            if (assemblyDescriptor != null) {
                List<ApplicationException> applicationExceptions = assemblyDescriptor.getApplicationExceptionList();
                if (!applicationExceptions.isEmpty()) {
                    Map<String, javax.ejb.ApplicationException> appExMap = new HashMap<String, javax.ejb.ApplicationException>(); // F743-14982
                    for (ApplicationException appEx : applicationExceptions) {
                        String className = appEx.getExceptionClassName();
                        appExMap.put(className, new ApplicationExceptionImpl(appEx.isRollback(), appEx.isInherited())); // F743-14982
                    }

                    if (isTraceOn && tc.isEntryEnabled())
                        Tr.exit(tc, "createApplicationExceptionMap : " + appExMap.size());

                    return appExMap;
                }
            }
        }

        if (isTraceOn && tc.isEntryEnabled())
            Tr.exit(tc, "createApplicationExceptionMap : null");

        return null;
    }
624623
private EJBException mapException(Throwable ex)
    {
        EJBException ejbex;
        boolean createdEx = true;
        Exception causeEx = null;

        if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled())
            Tr.entry(tc, "mapException: " + ex);

        // -----------------------------------------------------------------------
        // First, obtain the message text used to create the exception.
        //
        // If the message being mapped ends up being 'replaced', then the
        // replacement should have the same message text.
        //
        // getBaseMessage insures that the message text does NOT include the
        // name of the exception class, nor any chained exception text.
        // -----------------------------------------------------------------------
        String message = ExceptionUtil.getBaseMessage(ex);

        // -----------------------------------------------------------------------
        // Second, get the cause of the exception being mapped.
        //
        // findCause will remove any internal EJB Container exceptions from
        // the exception chain.
        //
        // Also, if the cause is not a subclass of Throwable, then it must
        // be 'wrapped' in an Exception, as EJBException does not allow
        // Throwable on any of its constructors.  However, the 'cause' on
        // throwable will still be set to the intended cause.  This will allow
        // getCause() to work as expected, even though EJBException does not
        // support Throwable.
        // -----------------------------------------------------------------------
        Throwable cause = ExceptionUtil.findCause(ex);

        if (cause != null)
        {
            if (cause instanceof Exception)
            {
                causeEx = (Exception) cause;
            }
            else
            {
                causeEx = new Exception("See nested Throwable", cause);
            }
        }

        // -----------------------------------------------------------------------
        // Next, map Throwable to an EJBException to return.
        //
        // These mappings are prescribed by the EJB & ActivitySession specs.
        //
        // Note: When adding new mappings, do NOT call 'initCause', as that
        //       will be performed below, and handles the fact that EJBException
        //       may not be created with a throwable.
        //
        // Caution: Do NOT look at the cause to perform mapping. If an exception
        //          is 'wrapped' in another exception, it likely was wrapped
        //          by another EJB method call, and a failure from a downstream
        //          method call should NOT be treated the same here.
        //          If it appears the cause needs to be examined, then instead,
        //          find the code that wrapped the cause, and stop wrapping it.
        // -----------------------------------------------------------------------
        if (ex instanceof CSIException)
        {
            ejbex = mapCSIException((CSIException) ex, causeEx, cause);
            createdEx = false;
        }
        else if (ex instanceof NoSuchObjectException)
        {
            ejbex = new NoSuchEJBException(message, causeEx);
        }
        else if (ex instanceof EJBStoppedException) // d350987
        {
            // Don't just replace the EJBStoppedException, but nest it as the
            // cause so applications may check for it.
            cause = ex;
            causeEx = (Exception) ex;
            ejbex = new NoSuchEJBException((String) null, causeEx);
        }
        else if (ex instanceof TransactionRequiredException)
        {
            ejbex = new EJBTransactionRequiredException(message); // d395666
        }
        else if (ex instanceof TransactionRolledbackException)
        {
            ejbex = new EJBTransactionRolledbackException(message, causeEx); // d395666
        }
        else if (ex instanceof InvalidTransactionException)
        {
            ejbex = new InvalidTransactionLocalException(message, causeEx);
        }
        else if (ex instanceof AccessException)
        {
            ejbex = new EJBAccessException(message); // d395666
        }
        //        else if (ex instanceof ActivityRequiredException)
//        {
//            ejbex = new ActivityRequiredLocalException(message, causeEx);
//        }
//        else if (ex instanceof InvalidActivityException)
//        {
//            ejbex = new InvalidActivityLocalException(message, causeEx);
//        }
//        else if (ex instanceof ActivityCompletedException)
//        {
//            ejbex = new ActivityCompletedLocalException(message, causeEx);
//        }
        else if (ex instanceof BeanNotReentrantException)
        {
            BeanNotReentrantException bnre = (BeanNotReentrantException) ex;
            if (bnre.isTimeout())
            {
                // EJB 3.1 has defined an exception for this purpose.      d653777.1
                ejbex = new ConcurrentAccessTimeoutException(message);
            }
            else
            {
                // EJB 3.0 has defined an exception for this purpose.      d366807.6
                ejbex = new ConcurrentAccessException(message, causeEx);
            }
        }
        else
        {
            // --------------------------------------------------------------------
            // All other exceptions are just be mapped to an EJBException.
            //
            // If the exception is an EJBException, it will just be returned
            // (with the throwable cause filled in), else the exception will
            // just be wrapped in an EJBException, with the stack and cause
            // set appropriately.
            // --------------------------------------------------------------------
            ejbex = ExceptionUtil.EJBException(ex);
            createdEx = false;
        }

        // -----------------------------------------------------------------------
        // Finally, EJBException doesn't normally set the cause on Throwable,
        // so let's do that to be nice :-) and clear the stack of the
        // EJBException, as it is mostly confusing and causes very
        // similar stacks to be printed out twice.
        //
        // Note that this code, especially clearing of the stack, is only
        // performed for EJBExceptions that were created in this method.
        // EJBExceptions that will just be propagated should NOT have the
        // stack cleared, as they were likely thrown by the customer.
        // -----------------------------------------------------------------------
        if (createdEx)
        {
            if (causeEx != null)
            {
                // Intentionally, the 'cause' is set as the 'cause', and not
                // 'causeEx'.  They will be the same, except when 'causeEx'
                // is just a silly wrapper around a Throwable.
                //
                // Geronimo EJBException.getCause returns getCausedbyException, so
                // we do not expect this code to be used.                     F53643
                if (ejbex.getCause() == null) { //F743-16279
                    // Use the 'real' cause here, not the possibly wrapped one.
                    ejbex.initCause(cause);
                }
            }
            else
            {
                ejbex.setStackTrace(ex.getStackTrace());
            }
        }

        if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled())
            Tr.exit(tc, "mapException returning: " + ejbex);

        return ejbex;
    }
1306803
public static <T> ThriftListenableFuture<T> failedListenableFuture(Exception e) {
        final ThriftListenableFuture<T> future = new ThriftListenableFuture<>();
        future.onError(e);
        return future;
    }
556487
public static function makeFromException($e)
    {
        if ($e instanceof self) {
            return $e;
        }

        return new static($e->getMessage(), $e->getCode(), $e);
    }
159695
protected SQLException translateException(Exception e) {
        if (isAcquireTimeoutException(e)) {
            eventPublisher.publish(new ConnectionAcquireTimeoutEvent(configurationProperties.getUniqueName()));
            return new AcquireTimeoutException(e);
        } else if (e instanceof SQLException) {
            return (SQLException) e;
        }
        return new SQLException(e);
    }
432110
public static RuntimeException asRuntime(Throwable e) {
		if (e instanceof RuntimeException) {
			return (RuntimeException) e;
		} else {
			return new WrappedAsRuntimeException(e);
		}
	}
1015841
public static<R> Result<R> err(Exception e) {
		return new Result<R>(null,ERR_General,e.getMessage(),EMPTY_VARS);
	}
477156
def exception(self, e):
        
        self.logged_exception(e)
        self.logger.exception(e)
792350
def _from_exception(cls, pe):
        
        return cls(pe.pstr, pe.loc, pe.msg, pe.parserElement)
1252435
protected SofaRpcException convertToRpcException(InvocationTargetException e) {
        SofaRpcException exception;
        Throwable ie = e.getCause(); // 包装的原因
        if (ie != null) {
            Throwable realException = ie.getCause(); // 真正的原因
            if (realException != null) {
                if (realException instanceof SocketTimeoutException) {
                    exception = new SofaRpcException(RpcErrorType.CLIENT_TIMEOUT, "Client read timeout!", realException);
                } else if (realException instanceof ConnectException) {
                    open = false;
                    exception = new SofaRpcException(RpcErrorType.CLIENT_NETWORK,
                        "Connect to remote " + transportConfig.getProviderInfo()
                            + " error!", realException);
                } else {
                    exception = new SofaRpcException(RpcErrorType.CLIENT_UNDECLARED_ERROR,
                        "Send message to remote catch error: " + realException.getMessage(), realException);
                }
            } else {
                exception = new SofaRpcException(RpcErrorType.CLIENT_UNDECLARED_ERROR,
                    "Send message to remote catch error: " + ie.getMessage(), ie);
            }
        } else {
            exception = new SofaRpcException(RpcErrorType.CLIENT_UNDECLARED_ERROR,
                "Send message to remote catch error: " + e.getMessage(), e);
        }
        return exception;
    }