From de2d582fa03bfbf1a07998b7774f30f3a91d3d25 Mon Sep 17 00:00:00 2001 From: Pingex Date: Sat, 28 May 2016 13:07:01 +0200 Subject: [PATCH] Super Debug 9000 mode. --- .../net/pingex/discordbot/DiscordBot.java | 64 ++++++++++++------- 1 file changed, 42 insertions(+), 22 deletions(-) diff --git a/src/main/java/net/pingex/discordbot/DiscordBot.java b/src/main/java/net/pingex/discordbot/DiscordBot.java index ad9f580..5919181 100644 --- a/src/main/java/net/pingex/discordbot/DiscordBot.java +++ b/src/main/java/net/pingex/discordbot/DiscordBot.java @@ -89,34 +89,54 @@ class DiscordBot */ public static void main(String[] args) { - // SET UP - System.setProperty("java.util.logging.SimpleFormatter.format", "%1$tY-%1$tm-%1$td %1$tH:%1$tM:%1$tS [%2$s/%4$s] %5$s%6$s%n"); + // SUPER DEBUG 9000 + Thread.setDefaultUncaughtExceptionHandler((t, e) -> { + System.out.println("Uncaught thread exception - " + e.getMessage()); + e.printStackTrace(System.out); - LOGGER.info("Hello World, starting up"); - LOGGER.info("DiscordBot version " + (DiscordBot.class.getPackage().getImplementationVersion() != null ? DiscordBot.class.getPackage().getImplementationVersion() : "UNKNOWN")); + System.err.println("Uncaught thread exception - " + e.getMessage()); + e.printStackTrace(System.err); + }); - // LOAD CONFIGURATION try { - Configuration.loadConfiguration("config.ini"); // TODO: pass configuration file using commandline argument - } catch (IOException e) - { - LOGGER.severe("Could not load Configuration, reason: " + e.getMessage()); - System.exit(10); - } + // SET UP + System.setProperty("java.util.logging.SimpleFormatter.format", "%1$tY-%1$tm-%1$td %1$tH:%1$tM:%1$tS [%2$s/%4$s] %5$s%6$s%n"); - LOGGER.info("Logging in to Discord"); - try - { - loginToDiscord(); - } catch (ConfigurationException e) - { - LOGGER.severe("There is a problem with the Configuration: " + e.getMessage()); - System.exit(9); - } catch (DiscordException e) + LOGGER.info("Hello World, starting up"); + LOGGER.info("DiscordBot version " + (DiscordBot.class.getPackage().getImplementationVersion() != null ? DiscordBot.class.getPackage().getImplementationVersion() : "UNKNOWN")); + + // LOAD CONFIGURATION + try + { + Configuration.loadConfiguration("config.ini"); // TODO: pass configuration file using commandline argument + } catch (IOException e) + { + LOGGER.severe("Could not load Configuration, reason: " + e.getMessage()); + System.exit(10); + } + + LOGGER.info("Logging in to Discord"); + try + { + loginToDiscord(); + } catch (ConfigurationException e) + { + LOGGER.severe("There is a problem with the Configuration: " + e.getMessage()); + System.exit(9); + } catch (DiscordException e) + { + LOGGER.severe(e.getMessage()); + System.exit(2); + } + } + catch (Throwable e) { - LOGGER.severe(e.getMessage()); - System.exit(2); + System.out.println("Uncaught exception - " + e.getMessage()); + e.printStackTrace(System.out); + + System.err.println("Uncaught exception - " + e.getMessage()); + e.printStackTrace(System.err); } }