* simplify FormatDialog warning messages

This commit is contained in:
Reinhard Pointner 2014-11-18 17:14:18 +00:00
parent 229ad65aab
commit 5c1f56d685
2 changed files with 8 additions and 8 deletions

View File

@ -51,27 +51,27 @@ public class ExpressionFormatMethods {
/**
* Return a substring matching the given pattern or break.
*/
public static String match(String self, String pattern) {
public static String match(String self, String pattern) throws Exception {
return match(self, pattern, -1);
}
public static String match(String self, String pattern, int matchGroup) {
public static String match(String self, String pattern, int matchGroup) throws Exception {
Matcher matcher = compile(pattern, CASE_INSENSITIVE | UNICODE_CHARACTER_CLASS | MULTILINE).matcher(self);
if (matcher.find()) {
return (matcher.groupCount() > 0 && matchGroup < 0 ? matcher.group(1) : matcher.group(matchGroup < 0 ? 0 : matchGroup)).trim();
} else {
throw new IllegalArgumentException("Pattern not found");
throw new Exception("Pattern not found");
}
}
/**
* Return a list of all matching patterns or break.
*/
public static List<String> matchAll(String self, String pattern) {
public static List<String> matchAll(String self, String pattern) throws Exception {
return matchAll(self, pattern, 0);
}
public static List<String> matchAll(String self, String pattern, int matchGroup) {
public static List<String> matchAll(String self, String pattern, int matchGroup) throws Exception {
List<String> matches = new ArrayList<String>();
Matcher matcher = compile(pattern, CASE_INSENSITIVE | UNICODE_CHARACTER_CLASS | MULTILINE).matcher(self);
while (matcher.find()) {
@ -81,7 +81,7 @@ public class ExpressionFormatMethods {
if (matches.size() > 0) {
return matches;
} else {
throw new IllegalArgumentException("Pattern not found");
throw new Exception("Pattern not found");
}
}

View File

@ -530,8 +530,8 @@ public class FormatDialog extends JDialog {
} catch (CancellationException e) {
// ignore, cancelled tasks are obsolete anyway
} catch (Exception e) {
Exception cause = findCause(e, BindingException.class);
status.setText(getMessage(cause != null ? cause : e));
BindingException bindingException = findCause(e, BindingException.class);
status.setText(bindingException != null ? getMessage(bindingException) : String.format("%s: %s", e.getClass().getSimpleName(), e.getMessage()));
status.setIcon(ResourceManager.getIcon("status.warning"));
status.setVisible(true);
} finally {