From fa8f4d3380e38f591e713d81e488279250fa520f Mon Sep 17 00:00:00 2001 From: Reinhard Pointner Date: Wed, 19 Jun 2019 00:30:54 +0700 Subject: [PATCH] Improved logging when bad license text is passed in --- source/net/filebot/Settings.java | 11 +++++++---- source/net/filebot/util/PGP.java | 3 ++- 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/source/net/filebot/Settings.java b/source/net/filebot/Settings.java index 07b0bc30..e8427593 100644 --- a/source/net/filebot/Settings.java +++ b/source/net/filebot/Settings.java @@ -22,10 +22,10 @@ import net.filebot.UserFiles.FileChooser; import net.filebot.cli.ArgumentBean; import net.filebot.util.PreferencesList; import net.filebot.util.PreferencesMap; -import net.filebot.util.SystemProperty; import net.filebot.util.PreferencesMap.JsonAdapter; import net.filebot.util.PreferencesMap.PreferencesEntry; import net.filebot.util.PreferencesMap.StringAdapter; +import net.filebot.util.SystemProperty; import net.filebot.util.ui.SwingEventBus; public final class Settings { @@ -148,8 +148,9 @@ public final class Settings { public static void configureLicense(File file) { try { - configureLicense(findClearSignMessage(readTextFile(file))); - } catch (Exception e) { + configureLicense(readTextFile(file)); + } catch (Throwable e) { + debug.severe(e::toString); log.severe("Invalid License File: " + e.getMessage()); } } @@ -158,7 +159,9 @@ public final class Settings { try { log.info(importLicense(findClearSignMessage(text)) + " has been activated successfully."); } catch (Throwable e) { - log.severe("License Error: " + e.getMessage()); + debug.severe(e::toString); + debug.severe(text); + log.severe("Invalid License File: " + e.getMessage()); } // make sure license is validated and cached diff --git a/source/net/filebot/util/PGP.java b/source/net/filebot/util/PGP.java index 80674a87..0c10ca70 100644 --- a/source/net/filebot/util/PGP.java +++ b/source/net/filebot/util/PGP.java @@ -6,6 +6,7 @@ import static net.filebot.util.RegularExpressions.*; import java.io.ByteArrayInputStream; import java.io.InputStream; +import java.util.NoSuchElementException; import java.util.regex.Matcher; import java.util.regex.Pattern; @@ -62,7 +63,7 @@ public class PGP { return matcher.group(); } - throw new IllegalArgumentException("PGP SIGNED MESSAGE not found"); + throw new NoSuchElementException("PGP SIGNED MESSAGE not found"); } }