From: Matthew B. <mat...@co...> - 2005-06-21 19:33:26
Attachments:
logbook_exception.txt
BuildingServerUserException.java
|
At the moment whenever an exception gets thrown from a method in BuildingSession (or subclass) the calling code (normally a facility) logs the exception. The problem is that some of these errors are just users doing silly things and don't need to be logged. One example of this is when a user tries to remove a section from a logbook that contains questions a BuildingServerException is thrown from the LogBookSessionImpl.deleteSection() method. Now the LogBookSession.deleteSection() method may throw a BuildingServerException for a much more serious error as well (not being able to fing the logbook associated with the session). To allow us to still log the serious errors but ignore (but still display to the user) the others I create a new exception BuildingServerUserException that subclasses BuildingServerException and then a special catch clause can be added in places where it is needed. As an example attached is the patch that shows the changes to LogBookSessionImpl. Comments? -- +--Matthew Buckett-----------------------------------------+ | VLE Developer, Learning Technologies Group | | Tel: +44 (0) 1865 283660 http://www.oucs.ox.ac.uk/ | +------------Computing Services, University of Oxford------+ |
From: Antony C. <an...@sm...> - 2005-06-22 10:45:41
|
Matthew, you are a true code digger! Good idea, user exceptions should contain user-friendly message and could be used to report back to user (could still be logged at a finer level). Can't see that "You don't have access rights allowing you to delete sections here." is output to user in LogBookFacility!? Antony ps. after your Skye visit, can we now refer to you as (Matthew) The Bucket! On 21 Jun 2005, at 17:05, Matthew Buckett wrote: > At the moment whenever an exception gets thrown from a method in > BuildingSession (or subclass) the calling code (normally a facility) > logs the exception. > > The problem is that some of these errors are just users doing silly > things and don't need to be logged. One example of this is when a user > tries to remove a section from a logbook that contains questions a > BuildingServerException is thrown from the > LogBookSessionImpl.deleteSection() method. > > Now the LogBookSession.deleteSection() method may throw a > BuildingServerException for a much more serious error as well (not > being able to fing the logbook associated with the session). > > To allow us to still log the serious errors but ignore (but still > display to the user) the others I create a new exception > BuildingServerUserException that subclasses BuildingServerException > and then a special catch clause can be added in places where it is > needed. > > As an example attached is the patch that shows the changes to > LogBookSessionImpl. > > Comments? > > -- > +--Matthew Buckett-----------------------------------------+ > | VLE Developer, Learning Technologies Group | > | Tel: +44 (0) 1865 283660 http://www.oucs.ox.ac.uk/ | > +------------Computing Services, University of Oxford------+ > Index: src/org/bodington/logbook/server/LogBookSessionImpl.java > =================================================================== > RCS file: > /usr/cvs/src/master/bodington/src/org/bodington/logbook/server/ > LogBookSessionImpl.java,v > retrieving revision 1.6 > diff -u -r1.6 LogBookSessionImpl.java > --- src/org/bodington/logbook/server/LogBookSessionImpl.java 27 May > 2005 14:40:12 -0000 1.6 > +++ src/org/bodington/logbook/server/LogBookSessionImpl.java 21 Jun > 2005 15:55:31 -0000 > @@ -462,14 +462,17 @@ > * Deletes a specific section. > * > * @exception java.rmi.RemoteException > - * @exception BuildingServerException > + * @exception BuildingServerException Something went seriously wrong. > + * @exception BuildingServerUserException Something went wrong that > should > + * be reported to the user but probably doesn't need to be logged. > + * > */ > public void deleteSection( PrimaryKey section_id ) > throws RemoteException, BuildingServerException > { > LogBook lb = getLogBook(); > if ( !lb.checkPermission( Permission.EDIT ) ) > - throw new BuildingServerException( "You don't have access rights > allowing you to delete sections here." ); > + throw new BuildingServerUserException( "You don't have access > rights allowing you to delete sections here." ); > > invalidateCsvQuestionFile(); > > @@ -479,7 +482,7 @@ > LogBookQuestion[] questions = this.getQuestionsInOrder( > section.getLogBookSectionId() ); > > if ( questions!=null && questions.length>0 ) > - throw new BuildingServerException( "Can't delete sections that > contain questions." ); > + throw new BuildingServerUserException( "Can't delete sections that > contain questions." ); > > // delete it > section.delete(); > Index: src/org/bodington/logbook/servlet/LogBookFacility.java > =================================================================== > RCS file: > /usr/cvs/src/master/bodington/src/org/bodington/logbook/servlet/ > LogBookFacility.java,v > retrieving revision 1.7 > diff -u -r1.7 LogBookFacility.java > --- src/org/bodington/logbook/servlet/LogBookFacility.java 27 May 2005 > 14:40:12 -0000 1.7 > +++ src/org/bodington/logbook/servlet/LogBookFacility.java 21 Jun 2005 > 15:55:31 -0000 > @@ -66,6 +66,7 @@ > import org.bodington.logbook.server.*; > import org.bodington.database.PrimaryKey; > import org.bodington.server.BuildingContext; > +import org.bodington.server.BuildingServerUserException; > import org.bodington.server.BuildingSession; > import org.bodington.server.BuildingSessionManagerImpl; > import org.bodington.server.BuildingServerException; > @@ -1554,6 +1555,11 @@ > { > lb_session.deleteSection( section_id ); > } > + catch (BuildingServerUserException bsue) > + { > + out.write(bsue.getMessage()); > + return; > + } > catch ( BuildingServerException bsex ) > { > logException( out, "LogBookFacility", "deleteSection", > /* > ====================================================================== > The Bodington System Software License, Version 1.0 > > Copyright (c) 2001 The University of Leeds. All rights reserved. > > Redistribution and use in source and binary forms, with or without > modification, are permitted provided that the following conditions are > met: > > 1. Redistributions of source code must retain the above copyright > notice, > this list of conditions and the following disclaimer. > > 2. Redistributions in binary form must reproduce the above copyright > notice, this list of conditions and the following disclaimer in the > documentation and/or other materials provided with the distribution. > > 3. The end-user documentation included with the redistribution, if > any, > must include the following acknowledgement: "This product includes > software developed by the University of Leeds > (http://www.bodington.org/)." Alternately, this acknowledgement may > appear in the software itself, if and wherever such third-party > acknowledgements normally appear. > > 4. The names "Bodington", "Nathan Bodington", "Bodington System", > "Bodington Open Source Project", and "The University of Leeds" must > not be > used to endorse or promote products derived from this software without > prior written permission. For written permission, please contact > d.g...@le.... > > 5. The name "Bodington" may not appear in the name of products derived > from this software without prior written permission of the University > of > Leeds. > > THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED > WARRANTIES, INCLUDING, BUT NOT LIMITED TO, TITLE, THE IMPLIED > WARRANTIES > OF QUALITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO > EVENT SHALL THE UNIVERSITY OF LEEDS OR ITS CONTRIBUTORS BE LIABLE FOR > ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL > DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE > GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS > INTERRUPTION) > HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, > STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING > IN > ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE > POSSIBILITY OF SUCH DAMAGE. > ========================================================= > > This software was originally created by the University of Leeds and > may contain voluntary > contributions from others. For more information on the Bodington Open > Source Project, please > see http://bodington.org/ > > ====================================================================== > */ > > package org.bodington.server; > > import org.bodington.pool.ObjectPoolException; > > /** > * Class that should be thrown when an error is encountered that > should be show > * to the user but probably doesn't need to be logged. > * @author buckett > */ > public class BuildingServerUserException extends > BuildingServerException > { > > /** > * Create a new BuildingServerUserException. > * @param s The error message that will probably be show to the > user. > */ > public BuildingServerUserException(String s) > { > super(s); > } > > > } |
From: Matthew B. <mat...@co...> - 2005-06-22 11:51:01
|
Antony Corfield wrote: > Good idea, user exceptions should > contain user-friendly message and could be used to report back to user > (could still be logged at a finer level). Can't see that "You don't > have access rights allowing you to delete sections here." is output to > user in LogBookFacility!? Here: >> +++ src/org/bodington/logbook/servlet/LogBookFacility.java 21 Jun >> 2005 15:55:31 -0000 >> @@ -66,6 +66,7 @@ >> import org.bodington.logbook.server.*; >> import org.bodington.database.PrimaryKey; >> import org.bodington.server.BuildingContext; >> +import org.bodington.server.BuildingServerUserException; >> import org.bodington.server.BuildingSession; >> import org.bodington.server.BuildingSessionManagerImpl; >> import org.bodington.server.BuildingServerException; >> @@ -1554,6 +1555,11 @@ >> { >> lb_session.deleteSection( section_id ); >> } >> + catch (BuildingServerUserException bsue) >> + { >> + out.write(bsue.getMessage()); >> + return; >> + } >> catch ( BuildingServerException bsex ) >> { >> logException( out, "LogBookFacility", "deleteSection", > ps. after your Skye visit, can we now refer to you as (Matthew) The Bucket! After my close inspection I must say you have very nice toilets installed in your student halls ;-) -- +--Matthew Buckett-----------------------------------------+ | VLE Developer, Learning Technologies Group | | Tel: +44 (0) 1865 283660 http://www.oucs.ox.ac.uk/ | +------------Computing Services, University of Oxford------+ |
From: Antony C. <an...@sm...> - 2005-06-22 12:06:24
|
> > Good idea, user exceptions should >> contain user-friendly message and could be used to report back to >> user (could still be logged at a finer level). Can't see that "You >> don't have access rights allowing you to delete sections here." is >> output to user in LogBookFacility!? > > Here: Ok, I see you are using it to output message but I was referring to original LogBookFacility which I doesn't. |
From: Matthew B. <mat...@co...> - 2005-06-22 12:17:10
|
Antony Corfield wrote: >> > Good idea, user exceptions should >> >>> contain user-friendly message and could be used to report back to >>> user (could still be logged at a finer level). Can't see that "You >>> don't have access rights allowing you to delete sections here." is >>> output to user in LogBookFacility!? >> >> >> Here: > > Ok, I see you are using it to output message but I was referring to > original LogBookFacility which I doesn't. logException actually outputs the message to the user. Maybe the method should be renamed to logAndDisplayException()? -- +--Matthew Buckett-----------------------------------------+ | VLE Developer, Learning Technologies Group | | Tel: +44 (0) 1865 283660 http://www.oucs.ox.ac.uk/ | +------------Computing Services, University of Oxford------+ |
From: Antony C. <an...@sm...> - 2005-06-22 13:24:31
|
How about! logException( PrintWriter out, String sourceClassName, String sourceMethodName, String message, Throwable th, Level level ) logException( String sourceClassName, String sourceMethodName, String message, Throwable th, Level level ) logException( PrintWriter out, String sourceClassName, String sourceMethodName, String message, Throwable th)- level=Severe logException( String sourceClassName, String sourceMethodName, String message, Throwable th) - level=Severe userException( PrintWriter out, Throwable th ) - where message is freindly text On 22 Jun 2005, at 13:17, Matthew Buckett wrote: > Antony Corfield wrote: >>> > Good idea, user exceptions should >>> >>>> contain user-friendly message and could be used to report back to >>>> user (could still be logged at a finer level). Can't see that "You >>>> don't have access rights allowing you to delete sections here." is >>>> output to user in LogBookFacility!? >>> >>> >>> Here: >> Ok, I see you are using it to output message but I was referring to >> original LogBookFacility which I doesn't. > > logException actually outputs the message to the user. Maybe the > method should be renamed to logAndDisplayException()? > > -- > +--Matthew Buckett-----------------------------------------+ > | VLE Developer, Learning Technologies Group | > | Tel: +44 (0) 1865 283660 http://www.oucs.ox.ac.uk/ | > +------------Computing Services, University of Oxford------+ > > > ------------------------------------------------------- > SF.Net email is sponsored by: Discover Easy Linux Migration Strategies > from IBM. Find simple to follow Roadmaps, straightforward articles, > informative Webcasts and more! Get everything you need to get up to > speed, fast. http://ads.osdn.com/?ad_id=7477&alloc_id=16492&op=click > _______________________________________________ > Bodington-developers mailing list > Bod...@li... > https://lists.sourceforge.net/lists/listinfo/bodington-developers |