Produce a one line description of the throwable, suitable for error message
and log printing.

@param thrown thrown object
@return description of the thrown object
978256
public static String oneLiner(Throwable thrown)
  {
    StackTraceElement[] stack = thrown.getStackTrace();
    String topOfStack = null;
    if (stack.length > 0)
    {
      topOfStack = " at " + stack[0];
    }
    return thrown.toString() + topOfStack;
  }
261557
private void printDiagnosticOutput(Throwable throwable) {
        logger.error("The following output will help developers to diagnose the problem:");
        logger.error("---");
        logger.error(String.format("Product: perspective-shell %s", shellInformationProvider.getVersion()));
        
        ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
        PrintStream printStream = new PrintStream(byteArrayOutputStream);
        throwable.printStackTrace(printStream);
        String stackTrace = byteArrayOutputStream.toString();
        logger.error(String.format("Exception: %s", stackTrace));
    }
1175643
private String generateAbbreviatedExceptionMessage(final Throwable throwable) {

		final StringBuilder builder = new StringBuilder();
		builder.append(": ");
		builder.append(throwable.getClass().getCanonicalName());
		builder.append(": ");
		builder.append(throwable.getMessage());

		Throwable cause = throwable.getCause();
		while (cause != null) {
			builder.append('\n');
			builder.append("Caused by: ");
			builder.append(cause.getClass().getCanonicalName());
			builder.append(": ");
			builder.append(cause.getMessage());
			// make sure the exception cause is not itself to prevent infinite
			// looping
			assert (cause != cause.getCause());
			cause = (cause == cause.getCause() ? null : cause.getCause());
		}
		return builder.toString();
	}
234807
public static Throwable unwrapForPresentation(Throwable throwable) {
        if (throwable == null) {
            return null;
        }
        while (throwable instanceof ExecutionException || throwable instanceof IllegalStateException
                || throwable.getClass() == RuntimeException.class) {
            // unwrap causes from wrapping exceptions
            final Throwable cause = throwable.getCause();
            if (cause == null) {
                break;
            }
            final String message = throwable.getMessage();
            if (Strings.isNullOrEmpty(message) || cause.toString().equals(message)) {
                // run another iteration
                throwable = cause;
            } else {
                break;
            }
        }
        return throwable;
    }
166362
@Override
    protected String convertToString(Object value) throws Throwable {
		Text text = (Text) value;
		return text.getValue();
    }
1188037
public <T extends Throwable> T throwing(T throwable) {
        if (instanceofLAL) {
            ((LocationAwareLogger) logger).log(THROWING_MARKER, FQCN, LocationAwareLogger.ERROR_INT, "throwing", null, throwable);
        }
        return throwable;
    }
478717
@Override
    public void info(String message, Throwable throwable) {
        if(this.logger.isInfoEnabled()) {
            this.logger.info(buildMessage(message), throwable);
        }
    }
299471
public static String formatException(Throwable exception) {
		StringBuilder buffer = new StringBuilder();

		formatException(exception, buffer);

		return buffer.toString();
	}
964328
public static String formatThrowable(Throwable throwable) {
    assertInitialization();
    return XLog.sLogConfiguration.throwableFormatter.format(throwable);
  }
122454
protected void demo() throws Throwable {
	    MethodHandles.Lookup lookup = MethodHandles.lookup();
	    MethodType type = MethodType.methodType(String.class, int.class, int.class);
	    MethodHandle mh = lookup.findVirtual(String.class, "substring", type);
	    String str = (String) mh.invokeExact("Hello World", 1, 3);
	    System.out.println(str);
	}
940612
@Override
    public void throwing(String sourceClass, String sourceMethod, Throwable thrown) {
        if (isLoggable(Level.FINER)) {
            LogRecord logRecord = createLogRecord(Level.FINER, "THROW", null, sourceClass, sourceMethod, null, thrown);
            log(logRecord);
        }
    }
1111455
public static String dumpStack(final Throwable cause) {
        if (cause == null) {
            return "Throwable was null";
        }
        final StringWriter sw = new StringWriter();
        final PrintWriter s = new PrintWriter(sw);

        // This is very close to what Thread.dumpStack does.
        cause.printStackTrace(s);

        final String stack = sw.toString();
        try {
            sw.close();
        } catch (final IOException e) {
            LOG.warn("Could not close writer", e);
        }
        s.close();
        return stack;
    }
1051139
public static String getFullThrowableMsg (Throwable throwable) {
		StringBuilder resultBuilder = new StringBuilder ();
		resultBuilder.append (throwable.getClass ().getCanonicalName ())
				.append (": ")
				.append (throwable.getMessage ());

		StackTraceElement[] stackTraceElements = throwable.getStackTrace ();

		if (stackTraceElements != null) {
			if (stackTraceElements.length > 0) {
				resultBuilder.append ("\nStack Trace:\n");

				StackTraceElement stackTraceElement = stackTraceElements[0];
				resultBuilder.append ("\t")
						.append (stackTraceElement.getClassName ())
						.append (":")
						.append (stackTraceElement.getMethodName ())
						.append ("():")
						.append (stackTraceElement.getLineNumber ());

				for (int i = 1; i < stackTraceElements.length; i++) {
					stackTraceElement = stackTraceElements[i];
					resultBuilder.append ("\n\tat ")
							.append (stackTraceElement.getClassName ())
							.append (":")
							.append (stackTraceElement.getMethodName ())
							.append ("():")
							.append (stackTraceElement.getLineNumber ());
				}
			}
		}

		Throwable cause = throwable.getCause ();

		if (cause != null) {
			resultBuilder.append ("\nCaused by:\n")
					.append (getFullThrowableMsg (cause));
		}

		String fullThrowableMsg = resultBuilder.toString ();
		return fullThrowableMsg;
	}
1340583
public static RuntimeException propagate(Throwable throwable) {
    final Throwable t = Preconditions.checkNotNull(throwable, "throwable");
    if (t instanceof Error) {
      throw (Error) t;
    }
    if (t instanceof RuntimeException) {
      throw (RuntimeException) t;
    }

    throw new RuntimeException(t);
  }
1061052
public static String asString(Throwable self) {
        StringBuilderWriter sw = new StringBuilderWriter();

        try (PrintWriter pw = new PrintWriter(sw)) {
            self.printStackTrace(pw);
        }

        return sw.toString();
    }
328152
public static void printInfo(Object message)
	{
		
		if (message instanceof Throwable)
		{

			Throwable e = (Throwable) message;

			getLog(Debugger.class).info(stackTrace(e));
		}
		else

			getLog(Debugger.class).info(message);

	}
712010
private ParseTree parseThrowStatement() {
    SourcePosition start = getTreeStartLocation();
    eat(TokenType.THROW);
    ParseTree value = null;
    if (peekImplicitSemiColon()) {
      reportError("semicolon/newline not allowed after 'throw'");
    } else {
      value = parseExpression();
    }
    eatPossibleImplicitSemiColon();
    return new ThrowStatementTree(getTreeLocation(start), value);
  }