Use error message names that make sense. Differentiate between not allowing

something because the requester is not the owner of the table and trying to
boot onesself from the table.


git-svn-id: svn+ssh://src.earth.threerings.net/vilya/trunk@764 c613c5cb-e716-0410-b11b-feb51c14d237
This commit is contained in:
Michael Bayne
2008-10-23 20:20:14 +00:00
parent 8a76c0de9f
commit 244b9b22b8
3 changed files with 36 additions and 28 deletions
@@ -40,27 +40,33 @@ public class ParlorCodes extends InvocationCodes
/** The response code for a countered invitation. */ /** The response code for a countered invitation. */
public static const INVITATION_COUNTERED :int = 2; public static const INVITATION_COUNTERED :int = 2;
/** An error code explaining that an invitation was rejected because /** An error code explaining that an invitation was rejected because the invited user was not
* the invited user was not online at the time the invitation was * online at the time the invitation was received. */
* received. */
public static const INVITEE_NOT_ONLINE :String = "m.invitee_not_online"; public static const INVITEE_NOT_ONLINE :String = "m.invitee_not_online";
/** An error code returned when a user requests to join a table that /** An error code returned when a user requests to join a table that
* doesn't exist. */ * doesn't exist. */
public static const NO_SUCH_TABLE :String = "m.no_such_table"; public static const NO_SUCH_TABLE :String = "m.no_such_table";
/** An error code returned when a user requests to join a table at a /** An error code returned by the table services. */
* position that is not valid. */ public static const MUST_BE_CREATOR :String = "m.must_be_creator";
public static const INVALID_TABLE_POSITION :String =
"m.invalid_table_position";
/** An error code returned when a user requests to join a table in a /** An error code returned by the table services. */
* position that is already occupied. */ public static const NO_SELF_BOOT :String = "m.no_self_boot";
public static const TABLE_POSITION_OCCUPIED :String =
"m.table_position_occupied";
/** An error code returned when a user requests to leave a table that /** An error code returned by the table services. */
public static const TABLE_POSITION_OCCUPIED :String = "m.table_position_occupied";
/** An error code returned by the table services when a user requests to create or join a table
* but they're already sitting at another table. */
public static const ALREADY_AT_TABLE :String = "m.already_at_table";
/** An error code returned by the table services when a user requests to leave a table that
* they were not sitting at in the first place. */ * they were not sitting at in the first place. */
public static const NOT_AT_TABLE :String = "m.not_at_table"; public static const NOT_AT_TABLE :String = "m.not_at_table";
/** An error code returned by the table services for a request to join a table that the
* requester been banned from. */
public static const BANNED_FROM_TABLE :String = "m.banned_from_table";
} }
} }
@@ -44,25 +44,27 @@ public interface ParlorCodes extends InvocationCodes
* online at the time the invitation was received. */ * online at the time the invitation was received. */
public static final String INVITEE_NOT_ONLINE = "m.invitee_not_online"; public static final String INVITEE_NOT_ONLINE = "m.invitee_not_online";
/** An error code returned when a user requests to join a table that doesn't exist. */ /** An error code returned by the table services. */
public static final String NO_SUCH_TABLE = "m.no_such_table"; public static final String NO_SUCH_TABLE = "m.no_such_table";
/** An error code returned when a user requests to join a table at a position that is not /** An error code returned by the table services. */
* valid. */ public static final String MUST_BE_CREATOR = "m.must_be_creator";
public static final String INVALID_TABLE_POSITION = "m.invalid_table_position";
/** An error code returned when a user requests to join a table in a position that is already /** An error code returned by the table services. */
* occupied. */ public static final String NO_SELF_BOOT = "m.no_self_boot";
/** An error code returned by the table services. */
public static final String TABLE_POSITION_OCCUPIED = "m.table_position_occupied"; public static final String TABLE_POSITION_OCCUPIED = "m.table_position_occupied";
/** An error code returned when a user requests to create or join a table but they're already /** An error code returned by the table services when a user requests to create or join a table
* sitting at another table. */ * but they're already sitting at another table. */
public static final String ALREADY_AT_TABLE = "m.already_at_table"; public static final String ALREADY_AT_TABLE = "m.already_at_table";
/** An error code returned when a user requests to leave a table that they were not sitting at /** An error code returned by the table services when a user requests to leave a table that
* in the first place. */ * they were not sitting at in the first place. */
public static final String NOT_AT_TABLE = "m.not_at_table"; public static final String NOT_AT_TABLE = "m.not_at_table";
/** An error code returned when a user requests to join a table they've been banned from. */ /** An error code returned by the table services for a request to join a table that the
* requester been banned from. */
public static final String BANNED_FROM_TABLE = "m.banned_from_table"; public static final String BANNED_FROM_TABLE = "m.banned_from_table";
} }
@@ -278,7 +278,7 @@ public class TableManager
if (table == null) { if (table == null) {
throw new InvocationException(NO_SUCH_TABLE); throw new InvocationException(NO_SUCH_TABLE);
} else if (starter.getOid() != table.bodyOids[0]) { } else if (starter.getOid() != table.bodyOids[0]) {
throw new InvocationException(INVALID_TABLE_POSITION); throw new InvocationException(MUST_BE_CREATOR);
} else if (!table.mayBeStarted()) { } else if (!table.mayBeStarted()) {
throw new InvocationException(INTERNAL_ERROR); throw new InvocationException(INTERNAL_ERROR);
} }
@@ -302,10 +302,10 @@ public class TableManager
int position = ListUtil.indexOf(table.players, target); int position = ListUtil.indexOf(table.players, target);
if (position < 0) { if (position < 0) {
throw new InvocationException(NOT_AT_TABLE); throw new InvocationException(NOT_AT_TABLE);
} else if (booter.getOid() != table.bodyOids[0] || } else if (booter.getOid() != table.bodyOids[0]) {
booter.getOid() == table.bodyOids[position]) { throw new InvocationException(MUST_BE_CREATOR);
// Must be head of the table, and can't self-boot } else if (booter.getOid() == table.bodyOids[position]) {
throw new InvocationException(INVALID_TABLE_POSITION); throw new InvocationException(NO_SELF_BOOT);
} }
// Remember to keep him banned // Remember to keep him banned