Transforms the given throwable into an appropriate fetch exception. If
it already is a fetch exception, it is simply casted.

@param e required exception to transform
@return FetchException, never null
519199
public FetchException toFetchException(Throwable e) {
        FetchException fe = transformIntoFetchException(e);
        if (fe != null) {
            return fe;
        }

        Throwable cause = e.getCause();
        if (cause != null) {
            fe = transformIntoFetchException(cause);
            if (fe != null) {
                return fe;
            }
        } else {
            cause = e;
        }

        return new FetchException(cause);
    }
816535
private static ReflectionException handleException(String memberName, IllegalAccessException e) {
        LOGGER.error("Couldn't access member " + memberName, e);
        return new ReflectionException(e);
    }
491625
public function onExceptionHandle(\Throwable $e)
    {
        try {
            if ($e->getPrevious()) {
                $ce     = $e->getPrevious();
                $errMsg = dump($ce, false, true);
            } else {
                $errMsg = dump($e, false, true);
                $ce     = $e;
            }
            $this->getContext()->getLog()->error($errMsg);
            if ($this->getContext()->getOutput()) {
                $this->output('Internal Server Error', 500);
            }
        } catch (\Throwable $ne) {
            getInstance()->log->error('previous exception ' . dump($ce, false, true));
            getInstance()->log->error('handle exception ' . dump($ne, false, true));
        }
    }
578195
public static <E extends Throwable> @NonNull RuntimeException rethrow(final @NonNull Throwable exception) throws E {
    throw (E) exception;
  }
315166
public <E extends Exception> E findWrapped(Class<E> exceptionType) {
		
		if (exceptionType == null) {
			return null;
		}
		
		Throwable cause = getCause();
		
		while (true) {
			
			if (cause == null) {
				return null;
			}
			
			if (exceptionType.isInstance(cause)) {
				
				@SuppressWarnings("unchecked") E matchedCause = (E) cause;
				return matchedCause;
			}
			
			if (cause.getCause() == cause) {
				return null;
			}
			
			if (cause instanceof WrappedRuntimeException) {
				return ((WrappedRuntimeException) cause).findWrapped(exceptionType);
			}
			if (cause instanceof WrappedCheckedException) {
				return ((WrappedCheckedException) cause).findWrapped(exceptionType);
			}
			
			cause = cause.getCause();
		}
	}
609278
protected void onUnhandledException(WebURL webUrl, Throwable e) {
        if (myController.getConfig().isHaltOnError() && !(e instanceof IOException)) {
            throw new RuntimeException("unhandled exception", e);
        } else {
            String urlStr = (webUrl == null ? "NULL" : webUrl.getURL());
            logger.warn("Unhandled exception while fetching {}: {}", urlStr, e.getMessage());
            logger.info("Stacktrace: ", e);
            // Do nothing by default (except basic logging)
            // Sub-classed can override this to add their custom functionality
        }
    }
703895
public static UnitResponse createException(Throwable e) {
        return UnitResponse
                .createError(Group.CODE_EXCEPTION, e, null);
    }
532330
private static ReflectionException handleException(String methodName, NoSuchMethodException e) {
        LOGGER.error("Couldn't find method " + methodName, e);
        return new ReflectionException(e);
    }
831010
public static Throwable unwrap(Throwable t) {
        for (;;) {
            if (t == null)
                throw new NullPointerException();

            if (t instanceof java.util.concurrent.ExecutionException)
                t = t.getCause();
            else if (t instanceof java.lang.reflect.InvocationTargetException)
                t = t.getCause();
            else if (t.getClass().equals(RuntimeException.class) && t.getCause() != null)
                t = t.getCause();
            else
                return t;
        }
    }
316644
@Override
	public void setException(@NotNull Throwable e) {
		assert !isComplete();
		exception = e;
		completeExceptionally(e);
	}
393307
public static ConnectionException ToConnectionPoolException(Throwable e) {
        if (e instanceof ConnectionException) {
            return (ConnectionException) e;
        }
        LOGGER.debug(e.getMessage());
        if (e instanceof InvalidRequestException) {
            return new com.netflix.astyanax.connectionpool.exceptions.BadRequestException(e);
        }
        else if (e instanceof TProtocolException) {
            return new com.netflix.astyanax.connectionpool.exceptions.BadRequestException(e);
        }
        else if (e instanceof UnavailableException) {
            return new TokenRangeOfflineException(e);
        }
        else if (e instanceof SocketTimeoutException) {
            return new TimeoutException(e);
        }
        else if (e instanceof TimedOutException) {
            return new OperationTimeoutException(e);
        }
        else if (e instanceof NotFoundException) {
            return new com.netflix.astyanax.connectionpool.exceptions.NotFoundException(e);
        }
        else if (e instanceof TApplicationException) {
            return new ThriftStateException(e);
        }
        else if (e instanceof AuthenticationException || e instanceof AuthorizationException) {
            return new com.netflix.astyanax.connectionpool.exceptions.AuthenticationException(e);
        }
        else if (e instanceof SchemaDisagreementException) {
            return new com.netflix.astyanax.connectionpool.exceptions.SchemaDisagreementException(e);
        }
        else if (e instanceof TTransportException) {
            if (e.getCause() != null) {
                if (e.getCause() instanceof SocketTimeoutException) {
                    return new TimeoutException(e);
                }
                if (e.getCause().getMessage() != null) {
                    if (e.getCause().getMessage().toLowerCase().contains("connection abort")
                            || e.getCause().getMessage().toLowerCase().contains("connection reset")) {
                        return new ConnectionAbortedException(e);
                    }
                }
            }
            return new TransportException(e);
        }
        else {
            // e.getCause().printStackTrace();
            return new UnknownException(e);
        }
    }
770055
public static DeleteException fromThrowable(Throwable cause) {
    return (cause instanceof DeleteException)
                   ? (DeleteException) cause
                   : new DeleteException(cause);
  }
479263
private void exception(Throwable e)
    {
        try
        {
            _persistent=false;
            int error_code=HttpResponse.__500_Internal_Server_Error;
            
            if (e instanceof HttpException)
            {
                error_code=((HttpException)e).getCode();
                
                if (_request==null)
                    log.warn(e.toString());
                else
                    log.warn(_request.getRequestLine()+" "+e.toString());
                log.debug(LogSupport.EXCEPTION,e);
            }
            else if (e instanceof EOFException)
            {
                LogSupport.ignore(log,e);
                return;
            }
            else
            {
                _request.setAttribute("javax.servlet.error.exception_type",e.getClass());
                _request.setAttribute("javax.servlet.error.exception",e);
                
                if (_request==null)
                    log.warn(LogSupport.EXCEPTION,e);
                else
                    log.warn(_request.getRequestLine(),e);
            }
            
            if (_response != null && !_response.isCommitted())
            {
                _response.reset();
                _response.removeField(HttpFields.__TransferEncoding);
                _response.setField(HttpFields.__Connection,HttpFields.__Close);
                _response.sendError(error_code);
            }
        }
        catch(Exception ex)
        {
            LogSupport.ignore(log,ex);
        }
    }
500740
public static Exception rethrow(Throwable throwable) throws Error {
        try {
            throw throwable;
        } catch (Error error) {
            throw error;
        } catch (Exception exception) {
            return exception;
        } catch (Throwable throwable2) {
            return msg.undeclaredThrowable(throwable2);
        }
    }
526816
public static Throwable unwrap(@Nullable Throwable t) {
		if (t instanceof UncheckedException || t instanceof java.util.concurrent.ExecutionException
				|| t instanceof java.lang.reflect.InvocationTargetException
				|| t instanceof UndeclaredThrowableException) {
			return t.getCause();
		}

		return t;
	}
263157
static Throwable cause(Throwable e)
  {
    while (e.getCause() != null
        && (e instanceof InstantiationException
            || e instanceof InvocationTargetException
            || e.getClass().equals(RuntimeExceptionConfig.class))) {
      e = e.getCause();
    }
    
    return e;
  }
1270141
@Nonnull
    protected Throwable getResponseException(Throwable e) {
        // Unwrap execution exceptions.
        if (ExecutionException.class.isAssignableFrom(e.getClass())) {
            return getResponseException(e.getCause());
        }
        return e;
    }