Throw a useful exception if the parameters are invalid.
git-svn-id: svn+ssh://src.earth.threerings.net/narya/trunk@2828 542714f4-19e9-0310-aa3c-eee0fc999fb1
This commit is contained in:
@@ -1,5 +1,5 @@
|
|||||||
//
|
//
|
||||||
// $Id: RandomUtil.java,v 1.9 2003/06/04 00:03:58 mdb Exp $
|
// $Id: RandomUtil.java,v 1.10 2003/10/22 20:26:32 mdb Exp $
|
||||||
|
|
||||||
package com.threerings.util;
|
package com.threerings.util;
|
||||||
|
|
||||||
@@ -35,6 +35,10 @@ public class RandomUtil
|
|||||||
*/
|
*/
|
||||||
public static int getInt (int high, int low)
|
public static int getInt (int high, int low)
|
||||||
{
|
{
|
||||||
|
if (high - low - 1 <= 0) {
|
||||||
|
throw new IllegalArgumentException(
|
||||||
|
"Invalid range [high=" + high + ", low=" + low + "]");
|
||||||
|
}
|
||||||
return low + 1 + rand.nextInt(high - low - 1);
|
return low + 1 + rand.nextInt(high - low - 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user