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:
@@ -40,27 +40,33 @@ public class ParlorCodes extends InvocationCodes
|
||||
/** The response code for a countered invitation. */
|
||||
public static const INVITATION_COUNTERED :int = 2;
|
||||
|
||||
/** An error code explaining that an invitation was rejected because
|
||||
* the invited user was not online at the time the invitation was
|
||||
* received. */
|
||||
/** An error code explaining that an invitation was rejected because the invited user was not
|
||||
* online at the time the invitation was received. */
|
||||
public static const INVITEE_NOT_ONLINE :String = "m.invitee_not_online";
|
||||
|
||||
/** An error code returned when a user requests to join a table that
|
||||
* doesn't exist. */
|
||||
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
|
||||
* position that is not valid. */
|
||||
public static const INVALID_TABLE_POSITION :String =
|
||||
"m.invalid_table_position";
|
||||
/** An error code returned by the table services. */
|
||||
public static const MUST_BE_CREATOR :String = "m.must_be_creator";
|
||||
|
||||
/** An error code returned when a user requests to join a table in a
|
||||
* position that is already occupied. */
|
||||
public static const TABLE_POSITION_OCCUPIED :String =
|
||||
"m.table_position_occupied";
|
||||
/** An error code returned by the table services. */
|
||||
public static const NO_SELF_BOOT :String = "m.no_self_boot";
|
||||
|
||||
/** 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. */
|
||||
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. */
|
||||
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";
|
||||
|
||||
/** An error code returned when a user requests to join a table at a position that is not
|
||||
* valid. */
|
||||
public static final String INVALID_TABLE_POSITION = "m.invalid_table_position";
|
||||
/** An error code returned by the table services. */
|
||||
public static final String MUST_BE_CREATOR = "m.must_be_creator";
|
||||
|
||||
/** An error code returned when a user requests to join a table in a position that is already
|
||||
* occupied. */
|
||||
/** An error code returned by the table services. */
|
||||
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";
|
||||
|
||||
/** An error code returned when a user requests to create or join a table but they're already
|
||||
* sitting at another table. */
|
||||
/** 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 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
|
||||
* in the first place. */
|
||||
/** 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. */
|
||||
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";
|
||||
}
|
||||
|
||||
@@ -278,7 +278,7 @@ public class TableManager
|
||||
if (table == null) {
|
||||
throw new InvocationException(NO_SUCH_TABLE);
|
||||
} else if (starter.getOid() != table.bodyOids[0]) {
|
||||
throw new InvocationException(INVALID_TABLE_POSITION);
|
||||
throw new InvocationException(MUST_BE_CREATOR);
|
||||
} else if (!table.mayBeStarted()) {
|
||||
throw new InvocationException(INTERNAL_ERROR);
|
||||
}
|
||||
@@ -302,10 +302,10 @@ public class TableManager
|
||||
int position = ListUtil.indexOf(table.players, target);
|
||||
if (position < 0) {
|
||||
throw new InvocationException(NOT_AT_TABLE);
|
||||
} else if (booter.getOid() != table.bodyOids[0] ||
|
||||
booter.getOid() == table.bodyOids[position]) {
|
||||
// Must be head of the table, and can't self-boot
|
||||
throw new InvocationException(INVALID_TABLE_POSITION);
|
||||
} else if (booter.getOid() != table.bodyOids[0]) {
|
||||
throw new InvocationException(MUST_BE_CREATOR);
|
||||
} else if (booter.getOid() == table.bodyOids[position]) {
|
||||
throw new InvocationException(NO_SELF_BOOT);
|
||||
}
|
||||
|
||||
// Remember to keep him banned
|
||||
|
||||
Reference in New Issue
Block a user