[SCM] master: Refactor EndOfFileException and TimeoutException into MatchException.

cagney@sourceware.org cagney@sourceware.org
Mon Dec 17 17:25:00 GMT 2007


The branch, master has been updated
       via  b1956ae0e033bbecd1d58cdf732e806968e82e81 (commit)
      from  d2a0a36ecfd0058513e5a8a6d0d86572abbfa5ba (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email.

- Log -----------------------------------------------------------------
commit b1956ae0e033bbecd1d58cdf732e806968e82e81
Author: Andrew Cagney <cagney@redhat.com>
Date:   Mon Dec 17 12:24:52 2007 -0500

    Refactor EndOfFileException and TimeoutException into MatchException.
    
    2007-12-17  cagney  <cagney@redhat.com>
    
    	* MatchException.java: New.
    	* EndOfFileException.java: Extend MatchException.
    	(message()): Delete.
    	* TimeoutException.java: Ditto.

-----------------------------------------------------------------------

Summary of changes:
 frysk-sys/frysk/expunit/ChangeLog               |    7 +++++
 frysk-sys/frysk/expunit/EndOfFileException.java |   20 +-------------
 frysk-sys/frysk/expunit/MatchException.java     |   30 +++++++++++++++++++++++
 frysk-sys/frysk/expunit/TimeoutException.java   |   26 ++-----------------
 4 files changed, 42 insertions(+), 41 deletions(-)
 create mode 100644 frysk-sys/frysk/expunit/MatchException.java

First 500 lines of diff:
diff --git a/frysk-sys/frysk/expunit/ChangeLog b/frysk-sys/frysk/expunit/ChangeLog
index 1173518..25f737d 100644
--- a/frysk-sys/frysk/expunit/ChangeLog
+++ b/frysk-sys/frysk/expunit/ChangeLog
@@ -1,3 +1,10 @@
+2007-12-17  cagney  <cagney@redhat.com>
+
+	* MatchException.java: New.
+	* EndOfFileException.java: Extend MatchException.
+	(message()): Delete.
+	* TimeoutException.java: Ditto.
+
 2007-12-14  cagney  <cagney@redhat.com>
 
 	* EndOfFileException.java: Rename EofException.java.
diff --git a/frysk-sys/frysk/expunit/EndOfFileException.java b/frysk-sys/frysk/expunit/EndOfFileException.java
index e815132..48051c5 100644
--- a/frysk-sys/frysk/expunit/EndOfFileException.java
+++ b/frysk-sys/frysk/expunit/EndOfFileException.java
@@ -43,26 +43,10 @@ package frysk.expunit;
  * Thrown an an end-of-file is encountered and nothing else matches.
  */
 
-public class EndOfFileException extends RuntimeException {
+public class EndOfFileException extends MatchException {
     static final long serialVersionUID = 1;
 
-    private static String message(Match[] matches, String output) {
-	StringBuffer msg = new StringBuffer();
-	msg.append("End-of-file");
-	if (matches != null) {
-	    msg.append("; expecting: ");
-	    for (int i = 0; i < matches.length; i++) {
-		msg.append(" <<");
-		msg.append(matches.toString());
-		msg.append(">>");
-	    }
-	}
-	msg.append("; buffer <<");
-	msg.append(output);
-	msg.append(">>");
-	return msg.toString();
-    }
     EndOfFileException(Match[] matches, String output) {
-	super(message(matches, output));
+	super("end-of-file", matches, output);
     }
 }
diff --git a/frysk-sys/frysk/expunit/MatchException.java b/frysk-sys/frysk/expunit/MatchException.java
new file mode 100644
index 0000000..e59bedf
--- /dev/null
+++ b/frysk-sys/frysk/expunit/MatchException.java
@@ -0,0 +1,30 @@
+package frysk.expunit;
+
+class MatchException extends RuntimeException {
+    static final long serialVersionUID = 1;
+    private final String error;
+    private final Match[] matches;
+    private final String output;
+    MatchException(String error, Match[] matches, String output) {
+	super(error);
+	this.error = error;
+	this.matches = matches;
+	this.output = output;
+    }
+    public String getMessage() {
+	StringBuffer msg = new StringBuffer();
+	msg.append(error);
+	if (matches != null) {
+	    msg.append("; expecting: ");
+	    for (int i = 0; i < matches.length; i++) {
+		msg.append(" <<");
+		msg.append(matches.toString());
+		msg.append(">>");
+	    }
+	}
+	msg.append("; buffer <<");
+	msg.append(output);
+	msg.append(">>");
+	return msg.toString();
+    }
+}
\ No newline at end of file
diff --git a/frysk-sys/frysk/expunit/TimeoutException.java b/frysk-sys/frysk/expunit/TimeoutException.java
index 4f64398..d050720 100644
--- a/frysk-sys/frysk/expunit/TimeoutException.java
+++ b/frysk-sys/frysk/expunit/TimeoutException.java
@@ -44,30 +44,10 @@ package frysk.expunit;
  * pattern.
  */
 
-public class TimeoutException
-    extends RuntimeException
-{
+public class TimeoutException extends MatchException {
     static final long serialVersionUID = 1;
-    private static String message(long millisecondTimeout, Match[] matches, String output) {
-	StringBuffer msg = new StringBuffer();
-	msg.append("Timeout of " + millisecondTimeout + " expired");
-	if (matches != null) {
-	    msg.append("; expecting: ");
-	    for (int i = 0; i < matches.length; i++) {
-		msg.append(" <<");
-		msg.append(matches.toString());
-		msg.append(">>");
-	    }
-	}
-	msg.append("; buffer <<");
-	msg.append(output);
-	msg.append(">>");
-	return msg.toString();
-    }
 
-    TimeoutException (long millisecondTimeout, Match[] matches, String output)
-    {
-	super (message(millisecondTimeout, matches, output));
-	
+    TimeoutException(long millisecondTimeout, Match[] matches, String output) {
+	super("timeout of " + millisecondTimeout + "expired", matches, output);
     }
 }


hooks/post-receive
--
frysk system monitor/debugger



More information about the Frysk-cvs mailing list