mirror of
https://github.com/EngineHub/WorldEdit.git
synced 2025-01-24 12:44:56 +08:00
Improved error reporting for number format errors.
This commit is contained in:
parent
cf30a63018
commit
feee529095
@ -21,6 +21,7 @@
|
||||
|
||||
import java.util.*;
|
||||
import java.util.logging.Logger;
|
||||
import java.util.regex.Matcher;
|
||||
import java.io.*;
|
||||
import java.lang.reflect.Method;
|
||||
|
||||
@ -1167,6 +1168,8 @@ public boolean handleBlockLeftClick(LocalPlayer player, WorldVector clicked) {
|
||||
return false;
|
||||
}
|
||||
|
||||
private static final java.util.regex.Pattern numberFormatExceptionPattern = java.util.regex.Pattern.compile("^For input string: \"(.*)\"$");
|
||||
|
||||
/**
|
||||
*
|
||||
* @param player
|
||||
@ -1243,7 +1246,13 @@ public boolean handleCommand(LocalPlayer player, String[] split) {
|
||||
flushBlockBag(player, editSession);
|
||||
}
|
||||
} catch (NumberFormatException e) {
|
||||
player.printError("Number expected; string given.");
|
||||
final Matcher matcher = numberFormatExceptionPattern.matcher(e.getMessage());
|
||||
|
||||
if (matcher.matches()) {
|
||||
player.printError("Number expected; string \""+matcher.group(1)+"\" given.");
|
||||
} else {
|
||||
player.printError("Number expected; string given.");
|
||||
}
|
||||
} catch (IncompleteRegionException e) {
|
||||
player.printError("Make a region selection first.");
|
||||
} catch (UnknownItemException e) {
|
||||
|
Loading…
Reference in New Issue
Block a user