Example usage for org.apache.wicket.markup MarkupStream toString

List of usage examples for org.apache.wicket.markup MarkupStream toString

Introduction

In this page you can find the example usage for org.apache.wicket.markup MarkupStream toString.

Prototype

@Override
public String toString() 

Source Link

Usage

From source file:eu.uqasar.web.pages.errors.ErrorPage.java

License:Apache License

/**
 *
 * @param throwable// w  w  w  .j  a  v  a 2  s  . c  o  m
 * <p>
 * @return
 */
private String getErrorMessage(final Throwable throwable) {
    if (throwable != null) {
        StringBuilder sb = new StringBuilder(256);

        // first print the last cause
        List<Throwable> al = convertToList(throwable);
        int length = al.size() - 1;
        Throwable cause = al.get(length);
        sb.append("Last cause: ").append(cause.getMessage()).append('\n');
        if (throwable instanceof WicketRuntimeException) {
            String msg = throwable.getMessage();
            if ((msg != null) && (!msg.equals(cause.getMessage()))) {
                if (throwable instanceof MarkupException) {
                    MarkupStream stream = ((MarkupException) throwable).getMarkupStream();
                    if (stream != null) {
                        String text = "\n" + stream.toString();
                        if (msg.endsWith(text)) {
                            msg = msg.substring(0, msg.length() - text.length());
                        }
                    }
                }

                sb.append("WicketMessage: ");
                sb.append(msg);
                sb.append("\n\n");
            }
        }
        return sb.toString();
    } else {
        return "[Unknown]";
    }
}