summaryrefslogtreecommitdiffstats
path: root/src/com/vaadin/terminal/SystemError.java
diff options
context:
space:
mode:
authorHenri Sara <henri.sara@itmill.com>2009-05-11 09:19:03 +0000
committerHenri Sara <henri.sara@itmill.com>2009-05-11 09:19:03 +0000
commitadc8c0ad3573272c236040c3a76005b9e73a5737 (patch)
treea3860704dbd5b82dc6af38684b80f8ef79a32722 /src/com/vaadin/terminal/SystemError.java
parent5abc870dda584d0c2fc47fd5eec4ae3de3fa240e (diff)
downloadvaadin-framework-adc8c0ad3573272c236040c3a76005b9e73a5737.tar.gz
vaadin-framework-adc8c0ad3573272c236040c3a76005b9e73a5737.zip
#2904: initial bulk rename "com.itmill.toolkit" -> "com.vaadin"
- com.itmill.toolkit.external not yet fully renamed svn changeset:7715/svn branch:6.0
Diffstat (limited to 'src/com/vaadin/terminal/SystemError.java')
-rw-r--r--src/com/vaadin/terminal/SystemError.java132
1 files changed, 132 insertions, 0 deletions
diff --git a/src/com/vaadin/terminal/SystemError.java b/src/com/vaadin/terminal/SystemError.java
new file mode 100644
index 0000000000..6f29970f6b
--- /dev/null
+++ b/src/com/vaadin/terminal/SystemError.java
@@ -0,0 +1,132 @@
+/*
+@ITMillApache2LicenseForJavaFiles@
+ */
+
+package com.vaadin.terminal;
+
+import java.io.PrintWriter;
+import java.io.StringWriter;
+
+/**
+ * <code>SystemError</code> is a runtime exception caused by error in system.
+ * The system error can be shown to the user as it implements
+ * <code>ErrorMessage</code> interface, but contains technical information such
+ * as stack trace and exception.
+ *
+ * @author IT Mill Ltd.
+ * @version
+ * @VERSION@
+ * @since 3.0
+ */
+@SuppressWarnings("serial")
+public class SystemError extends RuntimeException implements ErrorMessage {
+
+ /**
+ * The cause of the system error. The cause is stored separately as JDK 1.3
+ * does not support causes natively.
+ */
+ private Throwable cause = null;
+
+ /**
+ * Constructor for SystemError with error message specified.
+ *
+ * @param message
+ * the Textual error description.
+ */
+ public SystemError(String message) {
+ super(message);
+ }
+
+ /**
+ * Constructor for SystemError with causing exception and error message.
+ *
+ * @param message
+ * the Textual error description.
+ * @param cause
+ * the throwable causing the system error.
+ */
+ public SystemError(String message, Throwable cause) {
+ super(message);
+ this.cause = cause;
+ }
+
+ /**
+ * Constructor for SystemError with cause.
+ *
+ * @param cause
+ * the throwable causing the system error.
+ */
+ public SystemError(Throwable cause) {
+ this.cause = cause;
+ }
+
+ /**
+ * @see com.vaadin.terminal.ErrorMessage#getErrorLevel()
+ */
+ public final int getErrorLevel() {
+ return ErrorMessage.SYSTEMERROR;
+ }
+
+ /**
+ * @see com.vaadin.terminal.Paintable#paint(com.vaadin.terminal.PaintTarget)
+ */
+ public void paint(PaintTarget target) throws PaintException {
+
+ target.startTag("error");
+ target.addAttribute("level", "system");
+
+ // Paint the error message
+ final String message = getLocalizedMessage();
+ if (message != null) {
+ target.addSection("h2", message);
+ }
+
+ // Paint the exception
+ if (cause != null) {
+ target.addSection("h3", "Exception");
+ final StringWriter buffer = new StringWriter();
+ cause.printStackTrace(new PrintWriter(buffer));
+ target.addSection("pre", buffer.toString());
+ }
+
+ target.endTag("error");
+
+ }
+
+ /**
+ * Gets cause for the error.
+ *
+ * @return the cause.
+ * @see java.lang.Throwable#getCause()
+ */
+ @Override
+ public Throwable getCause() {
+ return cause;
+ }
+
+ /* Documented in super interface */
+ public void addListener(RepaintRequestListener listener) {
+ }
+
+ /* Documented in super interface */
+ public void removeListener(RepaintRequestListener listener) {
+ }
+
+ /* Documented in super interface */
+ public void requestRepaint() {
+ }
+
+ /* Documented in super interface */
+ public void requestRepaintRequests() {
+ }
+
+ public String getDebugId() {
+ return null;
+ }
+
+ public void setDebugId(String id) {
+ throw new UnsupportedOperationException(
+ "Setting testing id for this Paintable is not implemented");
+ }
+
+}