From 65d54537977627d9519a3c5f829a17d1a3c26d74 Mon Sep 17 00:00:00 2001 From: Reinhard Pointner Date: Tue, 9 Aug 2016 02:00:17 +0800 Subject: [PATCH] Better error reporting for expressions that are too long --- source/net/filebot/ui/rename/FormatDialog.java | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/source/net/filebot/ui/rename/FormatDialog.java b/source/net/filebot/ui/rename/FormatDialog.java index 7fcd6e58..1e07bbd6 100644 --- a/source/net/filebot/ui/rename/FormatDialog.java +++ b/source/net/filebot/ui/rename/FormatDialog.java @@ -36,6 +36,7 @@ import java.util.concurrent.ThreadPoolExecutor; import java.util.concurrent.ThreadPoolExecutor.DiscardOldestPolicy; import java.util.concurrent.TimeUnit; import java.util.logging.Level; +import java.util.prefs.Preferences; import javax.script.ScriptException; import javax.swing.AbstractAction; @@ -696,6 +697,9 @@ public class FormatDialog extends JDialog { if (format.getExpression().isEmpty()) { throw new ScriptException("Expression is empty"); } + if (format.getExpression().length() > Preferences.MAX_VALUE_LENGTH) { + throw new ScriptException("Expression is limited to " + Preferences.MAX_VALUE_LENGTH + " characters"); + } // create new recent history and ignore duplicates Set recent = new LinkedHashSet(); @@ -718,6 +722,8 @@ public class FormatDialog extends JDialog { finish(true); } catch (ScriptException e) { log.log(Level.WARNING, ExceptionUtilities.getRootCauseMessage(e)); + } catch (Exception e) { + log.log(Level.WARNING, e.getMessage(), e); } } };