From 1c58b80e7eb9c1626d241c0f37b68f9fc2b083e9 Mon Sep 17 00:00:00 2001 From: Christos KK Loverdos Date: Thu, 3 May 2012 13:31:36 +0300 Subject: [PATCH] Aquarium internal error --- .../gr/grnet/aquarium/AquariumInternalError.scala | 52 ++++++++++++++++++++ .../aquarium/actor/service/user/UserActor.scala | 6 +-- 2 files changed, 55 insertions(+), 3 deletions(-) create mode 100644 src/main/scala/gr/grnet/aquarium/AquariumInternalError.scala diff --git a/src/main/scala/gr/grnet/aquarium/AquariumInternalError.scala b/src/main/scala/gr/grnet/aquarium/AquariumInternalError.scala new file mode 100644 index 0000000..a40e56f --- /dev/null +++ b/src/main/scala/gr/grnet/aquarium/AquariumInternalError.scala @@ -0,0 +1,52 @@ +/* + * Copyright 2011-2012 GRNET S.A. 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. + * + * THIS SOFTWARE IS PROVIDED BY GRNET S.A. ``AS IS'' AND ANY EXPRESS + * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL GRNET S.A OR + * 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. + * + * The views and conclusions contained in the software and + * documentation are those of the authors and should not be + * interpreted as representing official policies, either expressed + * or implied, of GRNET S.A. + */ + +package gr.grnet.aquarium + +/** + * Should be the base of all Aquarium-related internal errors. + * + * @author Christos KK Loverdos + */ + +class AquariumInternalError(cause: Throwable, message: String) extends RuntimeException(message, cause) { + if(message eq null) throw new IllegalArgumentException("Null message in exception") + + def this(cause: Throwable) = this(cause, "") + + def this(message: String) = this(null, message) + + def this(message: String, cause: Throwable) = this(cause, message) +} diff --git a/src/main/scala/gr/grnet/aquarium/actor/service/user/UserActor.scala b/src/main/scala/gr/grnet/aquarium/actor/service/user/UserActor.scala index 0c2ffee..2facf1f 100644 --- a/src/main/scala/gr/grnet/aquarium/actor/service/user/UserActor.scala +++ b/src/main/scala/gr/grnet/aquarium/actor/service/user/UserActor.scala @@ -41,13 +41,12 @@ import gr.grnet.aquarium.actor._ import gr.grnet.aquarium.user._ import gr.grnet.aquarium.util.shortClassNameOf -import gr.grnet.aquarium.util.chainOfCauses import gr.grnet.aquarium.util.date.TimeHelpers import gr.grnet.aquarium.actor.message.service.router._ import message.config.{ActorProviderConfigured, AquariumPropertiesLoaded} import gr.grnet.aquarium.event.im.IMEventModel import akka.config.Supervision.Temporary -import gr.grnet.aquarium.{AquariumException, Configurator} +import gr.grnet.aquarium.{AquariumInternalError, AquariumException, Configurator} /** @@ -157,7 +156,8 @@ class UserActor extends ReflectiveRoleableActor { val imEvent = event.imEvent // If we already have a userID but it does not match the incoming userID, then this is an internal error if(_havePartialState && (this._userID != imEvent.userID)) { - throw new AquariumException("Got userID = %s but already have userID = %s".format(imEvent.userID, this._userID)) + throw new AquariumInternalError( + "Got userID = %s but already have userID = %s".format(imEvent.userID, this._userID)) } // If we get an IMEvent without having a user state, then we query for the latest user state. -- 1.7.10.4