1
0
mirror of https://github.com/mitb-archive/filebot synced 2024-12-25 17:28:51 -05:00

* 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. * 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); 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); Matcher matcher = compile(pattern, CASE_INSENSITIVE | UNICODE_CHARACTER_CLASS | MULTILINE).matcher(self);
if (matcher.find()) { if (matcher.find()) {
return (matcher.groupCount() > 0 && matchGroup < 0 ? matcher.group(1) : matcher.group(matchGroup < 0 ? 0 : matchGroup)).trim(); return (matcher.groupCount() > 0 && matchGroup < 0 ? matcher.group(1) : matcher.group(matchGroup < 0 ? 0 : matchGroup)).trim();
} else { } else {
throw new IllegalArgumentException("Pattern not found"); throw new Exception("Pattern not found");
} }
} }
/** /**
* Return a list of all matching patterns or break. * 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); 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>(); List<String> matches = new ArrayList<String>();
Matcher matcher = compile(pattern, CASE_INSENSITIVE | UNICODE_CHARACTER_CLASS | MULTILINE).matcher(self); Matcher matcher = compile(pattern, CASE_INSENSITIVE | UNICODE_CHARACTER_CLASS | MULTILINE).matcher(self);
while (matcher.find()) { while (matcher.find()) {
@ -81,7 +81,7 @@ public class ExpressionFormatMethods {
if (matches.size() > 0) { if (matches.size() > 0) {
return matches; return matches;
} else { } 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) { } catch (CancellationException e) {
// ignore, cancelled tasks are obsolete anyway // ignore, cancelled tasks are obsolete anyway
} catch (Exception e) { } catch (Exception e) {
Exception cause = findCause(e, BindingException.class); BindingException bindingException = findCause(e, BindingException.class);
status.setText(getMessage(cause != null ? cause : e)); status.setText(bindingException != null ? getMessage(bindingException) : String.format("%s: %s", e.getClass().getSimpleName(), e.getMessage()));
status.setIcon(ResourceManager.getIcon("status.warning")); status.setIcon(ResourceManager.getIcon("status.warning"));
status.setVisible(true); status.setVisible(true);
} finally { } finally {