From c8808d230a8c4f938b6adb54eb250299a092d87c Mon Sep 17 00:00:00 2001
From: "David A. Madore" <david+git@madore.org>
Date: Mon, 19 Apr 2010 08:50:41 +0200
Subject: Use RuntimeException classes rather than Error to indicate errors.

---
 org/madore/damlengine/LangHelper.java        | 4 ++--
 org/madore/damlengine/TodoBodyElement.java   | 4 ++--
 org/madore/damlengine/TodoDamlElement.java   | 8 ++++----
 org/madore/damlengine/TodoStyleOrScript.java | 2 +-
 4 files changed, 9 insertions(+), 9 deletions(-)

(limited to 'org/madore')

diff --git a/org/madore/damlengine/LangHelper.java b/org/madore/damlengine/LangHelper.java
index e2a74db..c1d736c 100644
--- a/org/madore/damlengine/LangHelper.java
+++ b/org/madore/damlengine/LangHelper.java
@@ -24,7 +24,7 @@ public class LangHelper {
 
     public static void setLangNorec(Element node, String lang) {
 	if ( lang == null )
-	    throw new Error("lang is null in setLangNorec");
+	    throw new IllegalArgumentException("lang is null in setLangNorec");
 	node.setAttributeNS(DamlEngine.XML_NS, LANG, lang);
     }
 
@@ -46,7 +46,7 @@ public class LangHelper {
 
     public static void setLangRec(Element node, String lang) {
 	if ( lang == null )
-	    throw new Error("lang is null in setLangRec");
+	    throw new IllegalArgumentException("lang is null in setLangRec");
 	String parentLang = getLangRec(node.getParentNode());
 	if ( lang.equals(parentLang) )
 	    unsetLangNorec(node);
diff --git a/org/madore/damlengine/TodoBodyElement.java b/org/madore/damlengine/TodoBodyElement.java
index c2be164..c5cc6c8 100644
--- a/org/madore/damlengine/TodoBodyElement.java
+++ b/org/madore/damlengine/TodoBodyElement.java
@@ -22,7 +22,7 @@ public class TodoBodyElement extends TodoDefaultElement {
 
     public void handleNodeOnly() {
 	if ( ! ( options instanceof TodoDamlElement.DamlOptions ) )
-	    throw new Error("body node can only be child of daml node");
+	    throw new IllegalArgumentException("body node can only be child of daml node");
 
 	Element bodyNode = ctx.doc.createElementNS(DamlEngine.XHTML_NS, "body");
 	String lang = LangHelper.getLangNorec(node);
@@ -53,7 +53,7 @@ public class TodoBodyElement extends TodoDefaultElement {
 	    if ( child.getNodeType() == Node.TEXT_NODE
 		 || child.getNodeType() == Node.CDATA_SECTION_NODE ) {
 		if ( ! Pattern.matches("^\\s*$",((CharacterData)child).getData()) )
-		    throw new Error("body element cannot contain text");
+		    throw new IllegalArgumentException("body element cannot contain text");
 	    }
 	    bodyNode.appendChild(child);
 	    if ( child.getNodeType() == Node.ELEMENT_NODE ) {
diff --git a/org/madore/damlengine/TodoDamlElement.java b/org/madore/damlengine/TodoDamlElement.java
index e7b9527..d177998 100644
--- a/org/madore/damlengine/TodoDamlElement.java
+++ b/org/madore/damlengine/TodoDamlElement.java
@@ -25,7 +25,7 @@ public class TodoDamlElement extends TodoDefaultElement {
 
     public void handleNodeOnly() {
 	if ( ! ( options instanceof DamlEngine.RootOptions ) )
-	    throw new Error("daml node can only be root node");
+	    throw new IllegalArgumentException("daml node can only be root node");
 	final String uriToTopName = "uri-to-top";
 	if ( node.hasAttributeNS(null, uriToTopName) )
 	    ctx.uriToTop = node.getAttributeNS(null, uriToTopName);
@@ -34,7 +34,7 @@ public class TodoDamlElement extends TodoDefaultElement {
 	    ctx.fileName = node.getAttributeNS(null, fileNameName);
 
 	if ( ctx.htmlNode != null )
-	    throw new Error("html node already defined at daml node");
+	    throw new IllegalStateException("html node already defined at daml node");
 	ctx.htmlNode = ctx.doc.createElementNS(DamlEngine.XHTML_NS, "html");
 	String lang = LangHelper.getLangNorec(node);
 	if ( lang != null )
@@ -44,7 +44,7 @@ public class TodoDamlElement extends TodoDefaultElement {
 	ctx.htmlNode.appendChild(ctx.doc.createComment(" This file is automatically generated.  Do not edit! "));
 	ctx.htmlNode.appendChild(ctx.doc.createTextNode("\n"));
 	if ( ctx.headNode != null )
-	    throw new Error("head node already defined at daml node");
+	    throw new IllegalStateException("head node already defined at daml node");
 	ctx.headNode = ctx.doc.createElementNS(DamlEngine.XHTML_NS, "head");
 	ctx.htmlNode.appendChild(ctx.headNode);
 	ctx.htmlNode.appendChild(ctx.doc.createTextNode("\n"));
@@ -92,7 +92,7 @@ public class TodoDamlElement extends TodoDefaultElement {
 	    } else if ( child.getNodeType() == Node.TEXT_NODE
 			|| child.getNodeType() == Node.CDATA_SECTION_NODE ) {
 		if ( ! Pattern.matches("^\\s*$",((CharacterData)child).getData()) )
-		    throw new Error("daml element cannot contain text");
+		    throw new IllegalArgumentException("daml element cannot contain text");
 	    }
 	}
 	this.ownerDeque.registerAtStart(toProcess);
diff --git a/org/madore/damlengine/TodoStyleOrScript.java b/org/madore/damlengine/TodoStyleOrScript.java
index 7b06955..4c04528 100644
--- a/org/madore/damlengine/TodoStyleOrScript.java
+++ b/org/madore/damlengine/TodoStyleOrScript.java
@@ -17,7 +17,7 @@ public class TodoStyleOrScript extends TodoItem {
 
     public void handle() {
 	if ( ctx.headNode == null )
-	    throw new Error("head node is null when doing style or script");
+	    throw new IllegalArgumentException("head node is null when doing style or script");
 	Element node
 	    = ctx.doc.createElementNS(DamlEngine.XHTML_NS,
 				      (t==Type.SCRIPT)?"script":"style");
-- 
cgit v1.2.3