From 742216d9de56393514d27b2e5a0e5e11b51c0a13 Mon Sep 17 00:00:00 2001 From: ray Date: Mon, 6 Sep 2004 00:03:15 +0000 Subject: [PATCH] A utility ResultListener that is silent on success, but logs as requested on failure. git-svn-id: https://samskivert.googlecode.com/svn/trunk@1502 6335cc39-0255-0410-8fd6-9bcaacd3b74c --- .../samskivert/util/ComplainingListener.java | 34 +++++++++++++++++++ 1 file changed, 34 insertions(+) create mode 100644 projects/samskivert/src/java/com/samskivert/util/ComplainingListener.java diff --git a/projects/samskivert/src/java/com/samskivert/util/ComplainingListener.java b/projects/samskivert/src/java/com/samskivert/util/ComplainingListener.java new file mode 100644 index 00000000..4fad7a01 --- /dev/null +++ b/projects/samskivert/src/java/com/samskivert/util/ComplainingListener.java @@ -0,0 +1,34 @@ +// +// $Id$ + +package com.samskivert.util; + + +/** + * A ResultListener that does nothing on success and logs a warning + * message on failure, that's all. + */ +public class ComplainingListener + implements ResultListener +{ + public ComplainingListener (Log log, String errorText) + { + _log = log; + _errorText = errorText; + } + + // documentation inherited from interface ResultListener + public void requestCompleted (Object result) { /* nada */ } + + // documentation inherited from interface ResultListener + public void requestFailed (Exception cause) + { + _log.warning(_errorText + " [cause=" + cause + "]."); + } + + /** The log to which we'll log our error. */ + protected Log _log; + + /** The text to output if the error happens. */ + protected String _errorText; +}