From 1203c5958862af49c0e2c8db12066cebf497d1cd Mon Sep 17 00:00:00 2001 From: Michael Bayne Date: Sat, 2 Apr 2011 00:48:01 +0000 Subject: [PATCH] Added a static method for concise condition requirey in invocation services. git-svn-id: svn+ssh://src.earth.threerings.net/narya/trunk@6583 542714f4-19e9-0310-aa3c-eee0fc999fb1 --- .../presents/server/InvocationException.java | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/src/main/java/com/threerings/presents/server/InvocationException.java b/src/main/java/com/threerings/presents/server/InvocationException.java index 400086afb..bd6e0fcf7 100644 --- a/src/main/java/com/threerings/presents/server/InvocationException.java +++ b/src/main/java/com/threerings/presents/server/InvocationException.java @@ -54,6 +54,18 @@ public class InvocationException extends Exception requireAccess(clobj, perm, null); } + /** + * Requires that the supplied condition be true, otherwise an invocation exception with the + * supplied error message is thrown. + */ + public static void require (boolean condition, String errmsg) + throws InvocationException + { + if (!condition) { + throw new InvocationException(errmsg); + } + } + /** * Constructs an invocation exception with the supplied cause code string. */