From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 20348 invoked by alias); 17 Dec 2007 17:25:34 -0000 Received: (qmail 20087 invoked by uid 367); 17 Dec 2007 17:25:29 -0000 Date: Mon, 17 Dec 2007 17:25:00 -0000 Message-ID: <20071217172529.20069.qmail@sourceware.org> From: cagney@sourceware.org To: frysk-cvs@sourceware.org Subject: [SCM] master: Refactor EndOfFileException and TimeoutException into MatchException. X-Git-Refname: refs/heads/master X-Git-Reftype: branch X-Git-Oldrev: d2a0a36ecfd0058513e5a8a6d0d86572abbfa5ba X-Git-Newrev: b1956ae0e033bbecd1d58cdf732e806968e82e81 Mailing-List: contact frysk-cvs-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Post: List-Help: , Sender: frysk-cvs-owner@sourceware.org Reply-To: frysk@sourceware.org X-SW-Source: 2007-q4/txt/msg00598.txt.bz2 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 Date: Mon Dec 17 12:24:52 2007 -0500 Refactor EndOfFileException and TimeoutException into MatchException. 2007-12-17 cagney * 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 + + * MatchException.java: New. + * EndOfFileException.java: Extend MatchException. + (message()): Delete. + * TimeoutException.java: Ditto. + 2007-12-14 cagney * 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