All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.greenpepper.annotation.ExceptionAnnotation Maven / Gradle / Ivy

There is a newer version: 4.2.4
Show newest version
package com.greenpepper.annotation;

import java.util.UUID;

import com.greenpepper.Text;
import com.greenpepper.util.ExceptionUtils;

/**
 * 

ExceptionAnnotation class.

* * @author oaouattara * @version $Id: $Id */ public class ExceptionAnnotation implements Annotation { private final Throwable error; /** *

Constructor for ExceptionAnnotation.

* * @param error a {@link java.lang.Throwable} object. */ public ExceptionAnnotation(Throwable error) { this.error = error; } /** {@inheritDoc} */ public void writeDown(Text text) { text.setStyle(Styles.BACKGROUND_COLOR, Colors.YELLOW); StringBuilder textContent = new StringBuilder(text.getContent()); textContent.append("
") .append(error.getClass().getSimpleName()) .append(": ") .append(error.getMessage()) .append(""); UUID randomUUID = UUID.randomUUID(); String expandButtonID = randomUUID.toString() + "-show"; textContent.append("\n+"); String collapseButtonID = randomUUID.toString() + "-hide"; textContent.append("\n-"); textContent.append("\n
")
            .append(ExceptionUtils.stackTrace(error, "\n", 10))
            .append("
"); text.setContent(textContent.toString()); } /** *

toString.

* * @return a {@link java.lang.String} object. */ public String toString() { return ExceptionUtils.stackTrace(error, "\n", 10); } /** *

getExceptionMessage.

* * @return a {@link java.lang.String} object. */ public String getExceptionMessage() { return error.getMessage(); } }




© 2015 - 2024 Weber Informatics LLC | Privacy Policy