You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@myfaces.apache.org by lo...@apache.org on 2017/11/30 09:48:42 UTC

[myfaces-tobago] branch master updated: TOBAGO-1782: Clean up * code style: Don't used unspecific exception, because of CWE-397: Declaration of Throws for Generic Exception In general, imho Tobago has no issue here, because the typical exception happens when Tobago is called by Server code, not by application developer code.

This is an automated email from the ASF dual-hosted git repository.

lofwyr pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/myfaces-tobago.git


The following commit(s) were added to refs/heads/master by this push:
     new c4ec157  TOBAGO-1782: Clean up * code style: Don't used unspecific exception, because of   CWE-397: Declaration of Throws for Generic Exception   In general, imho Tobago has no issue here, because   the typical exception happens when Tobago is called by   Server code, not by application developer code.
c4ec157 is described below

commit c4ec157875d5ce384b94f29a8610db8066402d2c
Author: Udo Schnurpfeil <lo...@apache.org>
AuthorDate: Thu Nov 30 10:47:21 2017 +0100

    TOBAGO-1782: Clean up
    * code style: Don't used unspecific exception, because of
      CWE-397: Declaration of Throws for Generic Exception
      In general, imho Tobago has no issue here, because
      the typical exception happens when Tobago is called by
      Server code, not by application developer code.
    
    * I've added some general exceptions, to counter this problem
---
 .../tobago/exception/TobagoConfigurationException.java  | 17 ++++++++++++++---
 .../myfaces/tobago/exception/TobagoException.java       | 17 ++++++++++++++---
 .../tobago/internal/behavior/DeltaStateHelper.java      |  6 ++++--
 .../tobago/internal/config/ContentSecurityPolicy.java   |  4 +++-
 .../tobago/internal/config/TobagoConfigBuilder.java     |  3 ++-
 .../tobago/internal/config/TobagoConfigImpl.java        |  7 ++++---
 .../tobago/internal/config/TobagoConfigParser.java      |  3 ++-
 .../tobago/internal/config/TobagoConfigSorter.java      |  5 +++--
 .../apache/myfaces/tobago/sanitizer/JsoupSanitizer.java |  7 ++++---
 .../ErrorTestException.java => demo/DemoException.java} |  6 +++---
 .../tobago/example/demo/ExceptionHandlerController.java |  2 +-
 .../tobago/example/demo/PartialReloadController.java    |  2 +-
 .../demo/bestpractice/BestPracticeController.java       |  3 ++-
 .../apache/myfaces/tobago/example/test/ErrorTest.java   |  4 +++-
 .../40-test/90000-attic/error/display-exception.xhtml   |  2 +-
 .../tobago/apt/processor/CheckstyleConfigGenerator.java |  2 +-
 .../myfaces/tobago/apt/processor/ClassesGenerator.java  |  6 +++---
 .../tobago/apt/processor/TobagoGeneratorException.java  | 13 ++++++++++---
 18 files changed, 75 insertions(+), 34 deletions(-)

diff --git a/tobago-example/tobago-example-demo/src/main/java/org/apache/myfaces/tobago/example/test/ErrorTestException.java b/tobago-core/src/main/java/org/apache/myfaces/tobago/exception/TobagoConfigurationException.java
similarity index 68%
copy from tobago-example/tobago-example-demo/src/main/java/org/apache/myfaces/tobago/example/test/ErrorTestException.java
copy to tobago-core/src/main/java/org/apache/myfaces/tobago/exception/TobagoConfigurationException.java
index c513318..324333e 100644
--- a/tobago-example/tobago-example-demo/src/main/java/org/apache/myfaces/tobago/example/test/ErrorTestException.java
+++ b/tobago-core/src/main/java/org/apache/myfaces/tobago/exception/TobagoConfigurationException.java
@@ -17,11 +17,22 @@
  * under the License.
  */
 
-package org.apache.myfaces.tobago.example.test;
+package org.apache.myfaces.tobago.exception;
 
-public class ErrorTestException extends RuntimeException {
+/**
+ * @since Tobago 4.0.0
+ */
+public class TobagoConfigurationException extends TobagoException {
 
-  public ErrorTestException(final String message) {
+  public TobagoConfigurationException(String message) {
     super(message);
   }
+
+  public TobagoConfigurationException(String message, Throwable cause) {
+    super(message, cause);
+  }
+
+  public TobagoConfigurationException(Throwable cause) {
+    super(cause);
+  }
 }
diff --git a/tobago-example/tobago-example-demo/src/main/java/org/apache/myfaces/tobago/example/test/ErrorTestException.java b/tobago-core/src/main/java/org/apache/myfaces/tobago/exception/TobagoException.java
similarity index 71%
copy from tobago-example/tobago-example-demo/src/main/java/org/apache/myfaces/tobago/example/test/ErrorTestException.java
copy to tobago-core/src/main/java/org/apache/myfaces/tobago/exception/TobagoException.java
index c513318..5a4ccac 100644
--- a/tobago-example/tobago-example-demo/src/main/java/org/apache/myfaces/tobago/example/test/ErrorTestException.java
+++ b/tobago-core/src/main/java/org/apache/myfaces/tobago/exception/TobagoException.java
@@ -17,11 +17,22 @@
  * under the License.
  */
 
-package org.apache.myfaces.tobago.example.test;
+package org.apache.myfaces.tobago.exception;
 
-public class ErrorTestException extends RuntimeException {
+/**
+ * @since Tobago 4.0.0
+ */
+public class TobagoException extends RuntimeException {
 
-  public ErrorTestException(final String message) {
+  public TobagoException(String message) {
     super(message);
   }
+
+  public TobagoException(String message, Throwable cause) {
+    super(message, cause);
+  }
+
+  public TobagoException(Throwable cause) {
+    super(cause);
+  }
 }
diff --git a/tobago-core/src/main/java/org/apache/myfaces/tobago/internal/behavior/DeltaStateHelper.java b/tobago-core/src/main/java/org/apache/myfaces/tobago/internal/behavior/DeltaStateHelper.java
index 70d0025..e3ee2fa 100644
--- a/tobago-core/src/main/java/org/apache/myfaces/tobago/internal/behavior/DeltaStateHelper.java
+++ b/tobago-core/src/main/java/org/apache/myfaces/tobago/internal/behavior/DeltaStateHelper.java
@@ -19,6 +19,8 @@
 
 package org.apache.myfaces.tobago.internal.behavior;
 
+import org.apache.myfaces.tobago.exception.TobagoException;
+
 import javax.el.ValueExpression;
 import javax.faces.component.StateHelper;
 import javax.faces.component.StateHolder;
@@ -744,10 +746,10 @@ class DeltaStateHelper<A extends EventBehavior> implements StateHelper {
       try {
         restoredObject = clazz.newInstance();
       } catch (final InstantiationException e) {
-        throw new RuntimeException("Could not restore StateHolder of type " + clazz.getName()
+        throw new TobagoException("Could not restore StateHolder of type " + clazz.getName()
             + " (missing no-args constructor?)", e);
       } catch (final IllegalAccessException e) {
-        throw new RuntimeException(e);
+        throw new TobagoException(e);
       }
       if (restoredObject instanceof StateHolder) {
         final AttachedStateWrapper wrapper = (AttachedStateWrapper) stateObj;
diff --git a/tobago-core/src/main/java/org/apache/myfaces/tobago/internal/config/ContentSecurityPolicy.java b/tobago-core/src/main/java/org/apache/myfaces/tobago/internal/config/ContentSecurityPolicy.java
index ad85096..a0964e6 100644
--- a/tobago-core/src/main/java/org/apache/myfaces/tobago/internal/config/ContentSecurityPolicy.java
+++ b/tobago-core/src/main/java/org/apache/myfaces/tobago/internal/config/ContentSecurityPolicy.java
@@ -19,6 +19,8 @@
 
 package org.apache.myfaces.tobago.internal.config;
 
+import org.apache.myfaces.tobago.exception.TobagoConfigurationException;
+
 import java.util.Collections;
 import java.util.HashMap;
 import java.util.Map;
@@ -32,7 +34,7 @@ public class ContentSecurityPolicy {
 
   private void checkLocked() throws IllegalStateException {
     if (unmodifiable) {
-      throw new RuntimeException("The configuration must not be changed after initialization!");
+      throw new TobagoConfigurationException("The configuration must not be changed after initialization!");
     }
   }
 
diff --git a/tobago-core/src/main/java/org/apache/myfaces/tobago/internal/config/TobagoConfigBuilder.java b/tobago-core/src/main/java/org/apache/myfaces/tobago/internal/config/TobagoConfigBuilder.java
index e88eee7..3545444 100644
--- a/tobago-core/src/main/java/org/apache/myfaces/tobago/internal/config/TobagoConfigBuilder.java
+++ b/tobago-core/src/main/java/org/apache/myfaces/tobago/internal/config/TobagoConfigBuilder.java
@@ -20,6 +20,7 @@
 package org.apache.myfaces.tobago.internal.config;
 
 import org.apache.myfaces.tobago.config.TobagoConfig;
+import org.apache.myfaces.tobago.exception.TobagoConfigurationException;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 import org.xml.sax.SAXException;
@@ -61,7 +62,7 @@ public class TobagoConfigBuilder {
     } catch (final Exception e) {
       final String error = "Error while deployment. Tobago can't be initialized! Application will not run correctly!";
       LOG.error(error, e);
-      throw new RuntimeException(error, e);
+      throw new TobagoConfigurationException(error, e);
     }
   }
 
diff --git a/tobago-core/src/main/java/org/apache/myfaces/tobago/internal/config/TobagoConfigImpl.java b/tobago-core/src/main/java/org/apache/myfaces/tobago/internal/config/TobagoConfigImpl.java
index 0982597..f306281 100644
--- a/tobago-core/src/main/java/org/apache/myfaces/tobago/internal/config/TobagoConfigImpl.java
+++ b/tobago-core/src/main/java/org/apache/myfaces/tobago/internal/config/TobagoConfigImpl.java
@@ -22,6 +22,7 @@ package org.apache.myfaces.tobago.internal.config;
 import org.apache.myfaces.tobago.config.TobagoConfig;
 import org.apache.myfaces.tobago.context.Theme;
 import org.apache.myfaces.tobago.context.ThemeImpl;
+import org.apache.myfaces.tobago.exception.TobagoConfigurationException;
 import org.apache.myfaces.tobago.sanitizer.Sanitizer;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
@@ -100,7 +101,7 @@ public class TobagoConfigImpl extends TobagoConfig {
 
   private void checkLocked() throws IllegalStateException {
     if (unmodifiable) {
-      throw new RuntimeException("The configuration must not be changed after initialization!");
+      throw new TobagoConfigurationException("The configuration must not be changed after initialization!");
     }
   }
 
@@ -134,7 +135,7 @@ public class TobagoConfigImpl extends TobagoConfig {
             + "Please ensure you have a tobago-config.xml with a theme-definition in your "
             + "theme JAR. Please add a theme JAR to your WEB-INF/lib";
         LOG.error(error);
-        throw new RuntimeException(error);
+        throw new TobagoConfigurationException(error);
       } else {
         if (LOG.isInfoEnabled()) {
           LOG.info("Using default Theme {}", defaultTheme.getName());
@@ -160,7 +161,7 @@ public class TobagoConfigImpl extends TobagoConfig {
           + "Please ensure you have a tobago-config.xml with a theme-definition in your "
           + "theme JAR. Found the following themes: " + availableThemes.keySet();
       LOG.error(error);
-      throw new RuntimeException(error);
+      throw new TobagoConfigurationException(error);
     }
   }
 
diff --git a/tobago-core/src/main/java/org/apache/myfaces/tobago/internal/config/TobagoConfigParser.java b/tobago-core/src/main/java/org/apache/myfaces/tobago/internal/config/TobagoConfigParser.java
index cb908f6..880ebd8 100644
--- a/tobago-core/src/main/java/org/apache/myfaces/tobago/internal/config/TobagoConfigParser.java
+++ b/tobago-core/src/main/java/org/apache/myfaces/tobago/internal/config/TobagoConfigParser.java
@@ -22,6 +22,7 @@ package org.apache.myfaces.tobago.internal.config;
 import org.apache.myfaces.tobago.context.ThemeImpl;
 import org.apache.myfaces.tobago.context.ThemeScript;
 import org.apache.myfaces.tobago.context.ThemeStyle;
+import org.apache.myfaces.tobago.exception.TobagoConfigurationException;
 import org.apache.myfaces.tobago.internal.util.IoUtils;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
@@ -342,7 +343,7 @@ public class TobagoConfigParser extends TobagoConfigEntityResolver {
         if (directiveName == null) { // before Tobago 4.0
           final int i = text.indexOf(' ');
           if (i < 1) {
-            throw new RuntimeException("CSP directive can't be parsed!");
+            throw new TobagoConfigurationException("CSP directive can't be parsed!");
           }
           tobagoConfig.getContentSecurityPolicy().addDirective(text.substring(0, i), text.substring(i + 1));
         } else {
diff --git a/tobago-core/src/main/java/org/apache/myfaces/tobago/internal/config/TobagoConfigSorter.java b/tobago-core/src/main/java/org/apache/myfaces/tobago/internal/config/TobagoConfigSorter.java
index 6d79395..fdb0ec7 100644
--- a/tobago-core/src/main/java/org/apache/myfaces/tobago/internal/config/TobagoConfigSorter.java
+++ b/tobago-core/src/main/java/org/apache/myfaces/tobago/internal/config/TobagoConfigSorter.java
@@ -20,6 +20,7 @@
 package org.apache.myfaces.tobago.internal.config;
 
 import org.apache.myfaces.tobago.context.ThemeImpl;
+import org.apache.myfaces.tobago.exception.TobagoConfigurationException;
 import org.apache.myfaces.tobago.sanitizer.IgnoringSanitizer;
 import org.apache.myfaces.tobago.sanitizer.JsoupSanitizer;
 import org.apache.myfaces.tobago.sanitizer.Sanitizer;
@@ -190,7 +191,7 @@ public class TobagoConfigSorter implements Comparator<TobagoConfigFragment> {
             buffer.append("'\n");
 
           }
-          throw new RuntimeException(buffer.toString());
+          throw new TobagoConfigurationException(buffer.toString());
         }
       }
   }
@@ -218,7 +219,7 @@ public class TobagoConfigSorter implements Comparator<TobagoConfigFragment> {
             buffer.append("'\n");
 
           }
-          throw new RuntimeException(buffer.toString());
+          throw new TobagoConfigurationException(buffer.toString());
         }
       }
     }
diff --git a/tobago-core/src/main/java/org/apache/myfaces/tobago/sanitizer/JsoupSanitizer.java b/tobago-core/src/main/java/org/apache/myfaces/tobago/sanitizer/JsoupSanitizer.java
index a57fada..cadd142 100644
--- a/tobago-core/src/main/java/org/apache/myfaces/tobago/sanitizer/JsoupSanitizer.java
+++ b/tobago-core/src/main/java/org/apache/myfaces/tobago/sanitizer/JsoupSanitizer.java
@@ -19,6 +19,7 @@
 
 package org.apache.myfaces.tobago.sanitizer;
 
+import org.apache.myfaces.tobago.exception.TobagoConfigurationException;
 import org.jsoup.Jsoup;
 import org.jsoup.safety.Whitelist;
 import org.slf4j.Logger;
@@ -68,11 +69,11 @@ public class JsoupSanitizer implements Sanitizer {
         } else if ("simpleText".equals(whitelistName)) {
           whitelist = Whitelist.simpleText();
         } else {
-          throw new RuntimeException(
+          throw new TobagoConfigurationException(
               "Unknown configuration value for 'whitelist' in tobago-config.xml found! value='" + whitelistName + "'");
         }
       } else {
-        throw new RuntimeException("Unknown configuration key in tobago-config.xml found! key='" + key + "'");
+        throw new TobagoConfigurationException("Unknown configuration key in tobago-config.xml found! key='" + key + "'");
       }
     }
 
@@ -83,7 +84,7 @@ public class JsoupSanitizer implements Sanitizer {
 
   private void checkLocked() throws IllegalStateException {
     if (unmodifiable) {
-      throw new RuntimeException("The configuration must not be changed after initialization!");
+      throw new TobagoConfigurationException("The configuration must not be changed after initialization!");
     }
   }
 
diff --git a/tobago-example/tobago-example-demo/src/main/java/org/apache/myfaces/tobago/example/test/ErrorTestException.java b/tobago-example/tobago-example-demo/src/main/java/org/apache/myfaces/tobago/example/demo/DemoException.java
similarity index 84%
copy from tobago-example/tobago-example-demo/src/main/java/org/apache/myfaces/tobago/example/test/ErrorTestException.java
copy to tobago-example/tobago-example-demo/src/main/java/org/apache/myfaces/tobago/example/demo/DemoException.java
index c513318..e6be8cf 100644
--- a/tobago-example/tobago-example-demo/src/main/java/org/apache/myfaces/tobago/example/test/ErrorTestException.java
+++ b/tobago-example/tobago-example-demo/src/main/java/org/apache/myfaces/tobago/example/demo/DemoException.java
@@ -17,11 +17,11 @@
  * under the License.
  */
 
-package org.apache.myfaces.tobago.example.test;
+package org.apache.myfaces.tobago.example.demo;
 
-public class ErrorTestException extends RuntimeException {
+public class DemoException extends RuntimeException {
 
-  public ErrorTestException(final String message) {
+  public DemoException(String message) {
     super(message);
   }
 }
diff --git a/tobago-example/tobago-example-demo/src/main/java/org/apache/myfaces/tobago/example/demo/ExceptionHandlerController.java b/tobago-example/tobago-example-demo/src/main/java/org/apache/myfaces/tobago/example/demo/ExceptionHandlerController.java
index 80d92bc..c2ce927 100644
--- a/tobago-example/tobago-example-demo/src/main/java/org/apache/myfaces/tobago/example/demo/ExceptionHandlerController.java
+++ b/tobago-example/tobago-example-demo/src/main/java/org/apache/myfaces/tobago/example/demo/ExceptionHandlerController.java
@@ -53,7 +53,7 @@ public class ExceptionHandlerController {
 
   public void update(final AjaxBehaviorEvent event) {
     if (((String) event.getComponent().getAttributes().get("value")).contains("x")) {
-      throw new RuntimeException("This exception is thrown, because the input value was 'x'.");
+      throw new DemoException("This exception is thrown, because the input value was 'x'.");
     }
     LOG.info("AjaxBehaviorEvent called. Current value: '{}'", value);
   }
diff --git a/tobago-example/tobago-example-demo/src/main/java/org/apache/myfaces/tobago/example/demo/PartialReloadController.java b/tobago-example/tobago-example-demo/src/main/java/org/apache/myfaces/tobago/example/demo/PartialReloadController.java
index 7224415..9aa18f9 100644
--- a/tobago-example/tobago-example-demo/src/main/java/org/apache/myfaces/tobago/example/demo/PartialReloadController.java
+++ b/tobago-example/tobago-example-demo/src/main/java/org/apache/myfaces/tobago/example/demo/PartialReloadController.java
@@ -52,7 +52,7 @@ public class PartialReloadController {
   }
 
   public String error() {
-    throw new RuntimeException("Test Exception");
+    throw new DemoException("Test Exception");
   }
   
   public String waitAndReload3() {
diff --git a/tobago-example/tobago-example-demo/src/main/java/org/apache/myfaces/tobago/example/demo/bestpractice/BestPracticeController.java b/tobago-example/tobago-example-demo/src/main/java/org/apache/myfaces/tobago/example/demo/bestpractice/BestPracticeController.java
index e2bd32c..83f2c71 100644
--- a/tobago-example/tobago-example-demo/src/main/java/org/apache/myfaces/tobago/example/demo/bestpractice/BestPracticeController.java
+++ b/tobago-example/tobago-example-demo/src/main/java/org/apache/myfaces/tobago/example/demo/bestpractice/BestPracticeController.java
@@ -20,6 +20,7 @@
 package org.apache.myfaces.tobago.example.demo.bestpractice;
 
 import org.apache.commons.io.IOUtils;
+import org.apache.myfaces.tobago.example.demo.DemoException;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
@@ -39,7 +40,7 @@ public class BestPracticeController {
   private String status;
 
   public String throwException() {
-    throw new RuntimeException("This exception is forced by the user.");
+    throw new DemoException("This exception is forced by the user.");
   }
 
   public String viewPdfInBrowser() {
diff --git a/tobago-example/tobago-example-demo/src/main/java/org/apache/myfaces/tobago/example/test/ErrorTest.java b/tobago-example/tobago-example-demo/src/main/java/org/apache/myfaces/tobago/example/test/ErrorTest.java
index 2f0f572..a2554dd 100644
--- a/tobago-example/tobago-example-demo/src/main/java/org/apache/myfaces/tobago/example/test/ErrorTest.java
+++ b/tobago-example/tobago-example-demo/src/main/java/org/apache/myfaces/tobago/example/test/ErrorTest.java
@@ -19,10 +19,12 @@
 
 package org.apache.myfaces.tobago.example.test;
 
+import org.apache.myfaces.tobago.example.demo.DemoException;
+
 public class ErrorTest {
 
   public String error() {
-    throw new ErrorTestException("This exception is thrown to test error pages");
+    throw new DemoException("This exception is thrown to test error pages");
   }
 
 }
diff --git a/tobago-example/tobago-example-demo/src/main/webapp/content/40-test/90000-attic/error/display-exception.xhtml b/tobago-example/tobago-example-demo/src/main/webapp/content/40-test/90000-attic/error/display-exception.xhtml
index b85ccec..cc113f5 100644
--- a/tobago-example/tobago-example-demo/src/main/webapp/content/40-test/90000-attic/error/display-exception.xhtml
+++ b/tobago-example/tobago-example-demo/src/main/webapp/content/40-test/90000-attic/error/display-exception.xhtml
@@ -32,7 +32,7 @@
 
       <tc:messages/>
       <tc:out
-          value="This page will be shown, when an org.apache.myfaces.tobago.example.test.ErrorTestException occures!"/>
+          value="This page will be shown, when an org.apache.myfaces.tobago.example.demo.DemoException occures!"/>
 
     </tc:box>
 
diff --git a/tobago-tool/tobago-tool-apt/src/main/java/org/apache/myfaces/tobago/apt/processor/CheckstyleConfigGenerator.java b/tobago-tool/tobago-tool-apt/src/main/java/org/apache/myfaces/tobago/apt/processor/CheckstyleConfigGenerator.java
index 4c91337..b80a65a 100644
--- a/tobago-tool/tobago-tool-apt/src/main/java/org/apache/myfaces/tobago/apt/processor/CheckstyleConfigGenerator.java
+++ b/tobago-tool/tobago-tool-apt/src/main/java/org/apache/myfaces/tobago/apt/processor/CheckstyleConfigGenerator.java
@@ -156,7 +156,7 @@ public class CheckstyleConfigGenerator extends AbstractGenerator {
         className = "org.apache.myfaces.tobago.internal.taglib." + StringUtils.capitalize(annotationTag.name())
             + "Tag";
       } else {
-        throw new RuntimeException("Not supported: " + typeElement.getQualifiedName());
+        throw new TobagoGeneratorException("Not supported: " + typeElement.getQualifiedName());
       }
       info("Replacing: " + typeElement.getQualifiedName() + " -> " + className);
       if (typeElement.getAnnotation(Deprecated.class) != null) {
diff --git a/tobago-tool/tobago-tool-apt/src/main/java/org/apache/myfaces/tobago/apt/processor/ClassesGenerator.java b/tobago-tool/tobago-tool-apt/src/main/java/org/apache/myfaces/tobago/apt/processor/ClassesGenerator.java
index 89ba2cd..239795a 100644
--- a/tobago-tool/tobago-tool-apt/src/main/java/org/apache/myfaces/tobago/apt/processor/ClassesGenerator.java
+++ b/tobago-tool/tobago-tool-apt/src/main/java/org/apache/myfaces/tobago/apt/processor/ClassesGenerator.java
@@ -92,7 +92,7 @@ public class ClassesGenerator extends AbstractGenerator {
         try {
           createTagOrComponent(element);
         } catch (final Exception e) {
-          throw new RuntimeException(
+          throw new TobagoGeneratorException(
               "Error during processing of " + element.getAnnotation(UIComponentTag.class).uiComponent(), e);
         }
       }
@@ -122,7 +122,7 @@ public class ClassesGenerator extends AbstractGenerator {
           componentInfo.getBehaviors().add(behavior.name());
           if (behavior.isDefault()) {
             if (componentInfo.getDefaultBehavior() != null) {
-              throw new RuntimeException("defaultBehavior '" + componentInfo.getDefaultBehavior()
+              throw new TobagoGeneratorException("defaultBehavior '" + componentInfo.getDefaultBehavior()
                   + "' will be overwritten with '" + behavior.name()
                   + "' in component '" + componentInfo.getSourceClass() + "'");
             }
@@ -130,7 +130,7 @@ public class ClassesGenerator extends AbstractGenerator {
           }
         }
         if (componentInfo.getDefaultBehavior() == null) {
-          throw new RuntimeException("defaultBehavior not set in component '" + componentInfo.getSourceClass() + "'");
+          throw new TobagoGeneratorException("defaultBehavior not set in component '" + componentInfo.getSourceClass() + "'");
         }
       }
 
diff --git a/tobago-example/tobago-example-demo/src/main/java/org/apache/myfaces/tobago/example/test/ErrorTestException.java b/tobago-tool/tobago-tool-apt/src/main/java/org/apache/myfaces/tobago/apt/processor/TobagoGeneratorException.java
similarity index 73%
rename from tobago-example/tobago-example-demo/src/main/java/org/apache/myfaces/tobago/example/test/ErrorTestException.java
rename to tobago-tool/tobago-tool-apt/src/main/java/org/apache/myfaces/tobago/apt/processor/TobagoGeneratorException.java
index c513318..fb63b67 100644
--- a/tobago-example/tobago-example-demo/src/main/java/org/apache/myfaces/tobago/example/test/ErrorTestException.java
+++ b/tobago-tool/tobago-tool-apt/src/main/java/org/apache/myfaces/tobago/apt/processor/TobagoGeneratorException.java
@@ -17,11 +17,18 @@
  * under the License.
  */
 
-package org.apache.myfaces.tobago.example.test;
+package org.apache.myfaces.tobago.apt.processor;
 
-public class ErrorTestException extends RuntimeException {
+/**
+ * @since Tobago 4.0.0
+ */
+public class TobagoGeneratorException extends RuntimeException {
 
-  public ErrorTestException(final String message) {
+  public TobagoGeneratorException(String message) {
     super(message);
   }
+
+  public TobagoGeneratorException(String message, Throwable cause) {
+    super(message, cause);
+  }
 }

-- 
To stop receiving notification emails like this one, please contact
['"commits@myfaces.apache.org" <co...@myfaces.apache.org>'].